postcss-nesting
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -0,1 +1,7 @@ | ||
## 2.3.0 (2016-02-20) | ||
- Updated: JavaScript formatting, linting, tests, and documentation | ||
- Updated: Properly concatenate at-rules with or expressions | ||
- Updated: Update internal plugin name to postcss-nesting | ||
## 2.2.0 (2016-01-30) | ||
@@ -2,0 +8,0 @@ |
22
index.js
var postcss = require('postcss'); | ||
var comma = postcss.list.comma; | ||
module.exports = postcss.plugin('postcss-nested', function (opts) { | ||
module.exports = postcss.plugin('postcss-nesting', function (opts) { | ||
var bubble = ['document', 'media', 'supports']; | ||
var name = 'nest'; | ||
if (opts && opts.bubble) bubble = bubble.concat(opts.bubble); | ||
if (opts && opts.prefix) name = '-' + opts.prefix + '-' + name; | ||
if (opts && opts.bubble) { | ||
bubble = bubble.concat(opts.bubble); | ||
} | ||
if (opts && opts.prefix) { | ||
name = '-' + opts.prefix + '-' + name; | ||
} | ||
return function (css) { | ||
@@ -37,3 +43,3 @@ css.walk(function (target) { | ||
rule.insertAfterNode = newrule; | ||
} else if (isAtRule && target.name === name && ~target.params.indexOf('&')) { | ||
} else if (isAtRule && target.name === name && target.params.indexOf('&') !== -1) { | ||
target.remove(); | ||
@@ -50,7 +56,11 @@ | ||
rule.insertAfterNode = newrule; | ||
} else if (isAtRule && ~bubble.indexOf(target.name)) { | ||
} else if (isAtRule && bubble.indexOf(target.name) !== -1) { | ||
var selector = rule.selector; | ||
if (root.type === 'atrule' && root.name === target.name && root.parent) { | ||
target.params = root.params + ' and ' + target.params; | ||
target.params = comma(root.params).map(function (params1) { | ||
return comma(target.params).map(function (params2) { | ||
return params1 + ' and ' + params2; | ||
}).join(', '); | ||
}).join(', '); | ||
@@ -57,0 +67,0 @@ rule = root; |
{ | ||
"name": "postcss-nesting", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Transpiles nested rules according to CSS Nesting Module Level 3", | ||
@@ -9,8 +9,13 @@ "keywords": [ | ||
"postcss-plugin", | ||
"atrules", | ||
"child", | ||
"children", | ||
"cssnext", | ||
"nested", | ||
"nestings", | ||
"rules", | ||
"selectors", | ||
"rules", | ||
"specifications", | ||
"specs", | ||
"specifications", | ||
"cssnext" | ||
"w3c" | ||
], | ||
@@ -23,6 +28,7 @@ "author": "Jonathan Neal <jonathantneal@hotmail.com>", | ||
"dependencies": { | ||
"postcss": "^5.0.14" | ||
"postcss": "^5.0.16" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^1.10.3", | ||
"jscs": "^2.10.1", | ||
"tap-spec": "^4.1.1", | ||
@@ -32,3 +38,3 @@ "tape": "^4.4.0" | ||
"scripts": { | ||
"lint": "eslint . --ignore-path .gitignore", | ||
"lint": "eslint *.js --ignore-path .gitignore && jscs *.js", | ||
"tape": "tape test.js | tap-spec", | ||
@@ -41,2 +47,2 @@ "test": "npm run lint && npm run tape" | ||
} | ||
} | ||
} |
@@ -10,3 +10,3 @@ # CSS Nesting | ||
```css | ||
/* at rule nesting */ | ||
/* direct nesting */ | ||
@@ -16,11 +16,11 @@ a, b { | ||
@nest & c, & d { | ||
& c, & d { | ||
color: white; | ||
} | ||
@nest & & { | ||
& & { | ||
color: blue; | ||
} | ||
@nest &:hover { | ||
&:hover { | ||
color: black; | ||
@@ -31,6 +31,10 @@ } | ||
color: yellow; | ||
@media (min-device-pixel-ratio: 1.5) { | ||
color: green; | ||
} | ||
} | ||
} | ||
/* direct nesting */ | ||
/* or at-rule nesting */ | ||
@@ -40,11 +44,11 @@ a, b { | ||
& c, & d { | ||
@nest & c, & d { | ||
color: white; | ||
} | ||
& & { | ||
@nest & & { | ||
color: blue; | ||
} | ||
&:hover { | ||
@nest &:hover { | ||
color: black; | ||
@@ -55,6 +59,2 @@ } | ||
color: yellow; | ||
@media (min-device-pixel-ratio: 1.5) { | ||
color: green; | ||
} | ||
} | ||
@@ -61,0 +61,0 @@ } |
@@ -65,3 +65,5 @@ var tests = { | ||
if (debug) fs.writeFileSync(actualPath, actualCSS); | ||
if (debug) { | ||
fs.writeFileSync(actualPath, actualCSS); | ||
} | ||
@@ -68,0 +70,0 @@ t.equal(actualCSS, expectCSS, message); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
24210
24
667
4
Updatedpostcss@^5.0.16