File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,28 @@ var LoadQueue = Class.create(/** @lends LoadQueue.prototype */{
130
130
var item = this . get ( id ) ;
131
131
return item && item . content ;
132
132
} ,
133
+ /**
134
+ * @language =en
135
+ * remove resource object content by id or src
136
+ * @param {String } specified id or src
137
+ */
138
+ /**
139
+ * @language =zh
140
+ * 根据id或src地址删除资源内容。
141
+ * @param {String } id 指定资源的id或src。
142
+ */
143
+ removeContent : function ( id ) {
144
+ if ( id ) {
145
+ var source = this . _source ;
146
+ for ( var i = 0 ; i < source . length ; i ++ ) {
147
+ var item = source [ i ] ;
148
+ if ( item . id === id || item . src === id ) {
149
+ source . splice ( i , 1 ) ;
150
+ return ;
151
+ }
152
+ }
153
+ }
154
+ } ,
133
155
134
156
/**
135
157
* @language =en
Original file line number Diff line number Diff line change @@ -97,6 +97,8 @@ describe('loader', function(){
97
97
queue . getContent ( 'btn' ) . should . instanceOf ( Image ) ;
98
98
queue . getContent ( 'btn' ) . width . should . equal ( 256 ) ;
99
99
queue . getContent ( 'btn' ) . height . should . equal ( 128 ) ;
100
+ queue . removeContent ( 'btn' ) ;
101
+ ( queue . getContent ( 'btn' ) == null ) . should . be . true ( ) ;
100
102
done ( ) ;
101
103
}
102
104
catch ( e ) {
You can’t perform that action at this time.
0 commit comments