fix: negative refs (#122)

master
Tomas Alabes 2017-03-26 14:02:00 -07:00 committed by Michael Ciniawsky
parent 0a27bfc4cf
commit f6f577a73c
2 changed files with 27 additions and 1 deletions

View File

@ -206,6 +206,32 @@ describe("basic tests", function() {
runCompilerTest(expected, done);
}); // it useable
it("useable without negative refs", function(done) {
cssRule.use = [
{
loader: "style-loader/useable"
},
"css-loader"
];
fs.writeFileSync(
rootDir + "main.js",
[
"var css = require('./style.css');",
"css.unuse();", // ref still 0
"css.use();", // ref 1
].join("\n")
);
// Run
let expected = [
existingStyle,
`<style type="text/css">${requiredCss}</style>`
].join("\n");
runCompilerTest(expected, done);
}); // it useable
it("local scope", function(done) {
cssRule.use = [
{

View File

@ -21,7 +21,7 @@ module.exports.pitch = function(remainingRequest) {
" return exports;",
"};",
"exports.unuse = exports.unref = function() {",
" if(!(--refs)) {",
" if(refs > 0 && !(--refs)) {",
" dispose();",
" dispose = null;",
" }",