File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,32 @@ describe("basic tests", function() {
206
206
runCompilerTest ( expected , done ) ;
207
207
} ) ; // it useable
208
208
209
+ it ( "useable without negative refs" , function ( done ) {
210
+ cssRule . use = [
211
+ {
212
+ loader : "style-loader/useable"
213
+ } ,
214
+ "css-loader"
215
+ ] ;
216
+
217
+ fs . writeFileSync (
218
+ rootDir + "main.js" ,
219
+ [
220
+ "var css = require('./style.css');" ,
221
+ "css.unuse();" , // ref still 0
222
+ "css.use();" , // ref 1
223
+ ] . join ( "\n" )
224
+ ) ;
225
+
226
+ // Run
227
+ let expected = [
228
+ existingStyle ,
229
+ `<style type="text/css">${ requiredCss } </style>`
230
+ ] . join ( "\n" ) ;
231
+
232
+ runCompilerTest ( expected , done ) ;
233
+ } ) ; // it useable
234
+
209
235
it ( "local scope" , function ( done ) {
210
236
cssRule . use = [
211
237
{
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ module.exports.pitch = function(remainingRequest) {
21
21
" return exports;" ,
22
22
"};" ,
23
23
"exports.unuse = exports.unref = function() {" ,
24
- " if(!(--refs)) {" ,
24
+ " if(refs > 0 && !(--refs)) {" ,
25
25
" dispose();" ,
26
26
" dispose = null;" ,
27
27
" }" ,
You can’t perform that action at this time.
0 commit comments