postcss-scopify
Advanced tools
Comparing version 0.1.9 to 0.1.10
24
index.js
'use strict'; | ||
var postcss = require('postcss'); | ||
var selectorParser = require('postcss-selector-parser'); | ||
@@ -12,2 +13,18 @@ var conditionalGroupRules = ['media','supports','document']; | ||
// special case for the '&' selector, resolves to scope | ||
var processor = selectorParser(function (selectors) { | ||
var hasNestingSelector = false; | ||
selectors.walkNesting(function (selector) { | ||
hasNestingSelector = true; | ||
selector.replaceWith( | ||
selectorParser.string({value: scope}) | ||
); | ||
}); | ||
if (!hasNestingSelector) { | ||
selectors.first.prepend( | ||
selectorParser.string({value: scope + ' '}) | ||
); | ||
} | ||
}); | ||
return function(root) { | ||
@@ -32,9 +49,4 @@ | ||
// special case for a top level '&' selector, resolves to scope | ||
if (selector === '&') { | ||
return scope; | ||
} | ||
return processor.processSync(selector); | ||
return scope + ' ' + selector; | ||
}); | ||
@@ -41,0 +53,0 @@ }); |
{ | ||
"name": "postcss-scopify", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "PostCSS plugin that adds a user input scope to each selector", | ||
@@ -24,3 +24,4 @@ "keywords": [ | ||
"dependencies": { | ||
"postcss": "^5.0.0" | ||
"postcss": "^5.0.0", | ||
"postcss-selector-parser": "^6.0.2" | ||
}, | ||
@@ -32,4 +33,4 @@ "devDependencies": { | ||
"scripts": { | ||
"test": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- -u exports test/*" | ||
"test": "istanbul cover ./node_modules/mocha/bin/_mocha -- -u exports test/*.js" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
7334
2
6
82
+ Addedcssesc@3.0.0(transitive)
+ Addedpostcss-selector-parser@6.1.2(transitive)
+ Addedutil-deprecate@1.0.2(transitive)