Skip to content

Commit

Permalink
fix: negative refs (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasAlabes authored and michael-ciniawsky committed Mar 26, 2017
1 parent 0a27bfc commit f6f577a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions test/basicTest.js
Expand Up @@ -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 = [
{
Expand Down
2 changes: 1 addition & 1 deletion useable.js
Expand Up @@ -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;",
" }",
Expand Down

0 comments on commit f6f577a

Please sign in to comment.