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() {
206206 runCompilerTest ( expected , done ) ;
207207 } ) ; // it useable
208208
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+
209235 it ( "local scope" , function ( done ) {
210236 cssRule . use = [
211237 {
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ module.exports.pitch = function(remainingRequest) {
2121 " return exports;" ,
2222 "};" ,
2323 "exports.unuse = exports.unref = function() {" ,
24- " if(!(--refs)) {" ,
24+ " if(refs > 0 && !(--refs)) {" ,
2525 " dispose();" ,
2626 " dispose = null;" ,
2727 " }" ,
You can’t perform that action at this time.
0 commit comments