postcss-nesting
Advanced tools
Comparing version 4.0.1 to 4.1.0
# Changes to PostCSS Nesting | ||
### 4.1.0 (August 19, 2017) | ||
- Improve complex selector validity testing | ||
- Use mutation-safe walk method | ||
- A special thanks to @JLHwung for these improvements | ||
### 4.0.1 (May 22, 2017) | ||
@@ -4,0 +10,0 @@ |
14
index.js
@@ -11,6 +11,6 @@ 'use strict'; | ||
module.exports = postcss.plugin('postcss-nesting', () => { | ||
return walk; | ||
return (root) => root.walk(transform); | ||
}); | ||
function walk(node) { | ||
function transform(node) { | ||
// console.log('walk', [node.type], [node.name || node.selector || node.prop || 'root'], node.nodes ? `length: ${node.nodes.length}` : `value: "${node.value}"`); | ||
@@ -29,12 +29,2 @@ | ||
if (node.nodes) { | ||
// conditionally walk the children of the node | ||
let childNode = node.nodes[0]; | ||
while (childNode) { | ||
walk(childNode); | ||
childNode = childNode.parent && childNode.parent.nodes[childNode.parent.nodes.indexOf(childNode) + 1]; | ||
} | ||
} | ||
} |
@@ -23,2 +23,5 @@ // tooling | ||
// clone atrule semicolon raws | ||
rule.raws = node.raws.semicolon ? { semicolon: true } : {}; | ||
// move the clone after the parent | ||
@@ -43,3 +46,3 @@ const parent = node.parent.after(rule); | ||
module.exports.test = (node) => node.type === 'atrule' && node.name === 'nest' && node.parent && node.parent.type === 'rule' && comma(node.params).every( | ||
(selector) => selector.split('&').length === 2 && /&([^\w-]|$)/.test(selector) | ||
(selector) => selector.split('&').length === 2 && /&([^\w-|]|$)/.test(selector) | ||
); |
@@ -28,3 +28,3 @@ // tooling | ||
module.exports.test = (node) => node.type === 'rule' && node.parent && node.parent.type === 'rule' && node.selectors.every( | ||
(selector) => selector.trim().lastIndexOf('&') === 0 && /^&([^\w-]|$)/.test(selector) | ||
(selector) => selector.trim().lastIndexOf('&') === 0 && /^&([^\w-|]|$)/.test(selector) | ||
); |
@@ -30,21 +30,21 @@ # CC0 1.0 Universal | ||
1. Copyright and Related Rights. A Work made available under CC0 may be | ||
protected by copyright and related or neighboring rights (“Copyright and | ||
Related Rights”). Copyright and Related Rights include, but are not limited | ||
to, the following: | ||
1. the right to reproduce, adapt, distribute, perform, display, | ||
communicate, and translate a Work; | ||
2. moral rights retained by the original author(s) and/or performer(s); | ||
3. publicity and privacy rights pertaining to a person’s image or likeness | ||
depicted in a Work; | ||
4. rights protecting against unfair competition in regards to a Work, | ||
subject to the limitations in paragraph 4(i), below; | ||
5. rights protecting the extraction, dissemination, use and reuse of data | ||
in a Work; | ||
6. database rights (such as those arising under Directive 96/9/EC of the | ||
European Parliament and of the Council of 11 March 1996 on the legal | ||
protection of databases, and under any national implementation thereof, | ||
including any amended or successor version of such directive); and | ||
7. other similar, equivalent or corresponding rights throughout the world | ||
based on applicable law or treaty, and any national implementations | ||
thereof. | ||
protected by copyright and related or neighboring rights (“Copyright and | ||
Related Rights”). Copyright and Related Rights include, but are not limited | ||
to, the following: | ||
1. the right to reproduce, adapt, distribute, perform, display, | ||
communicate, and translate a Work; | ||
2. moral rights retained by the original author(s) and/or performer(s); | ||
3. publicity and privacy rights pertaining to a person’s image or likeness | ||
depicted in a Work; | ||
4. rights protecting against unfair competition in regards to a Work, | ||
subject to the limitations in paragraph 4(i), below; | ||
5. rights protecting the extraction, dissemination, use and reuse of data | ||
in a Work; | ||
6. database rights (such as those arising under Directive 96/9/EC of the | ||
European Parliament and of the Council of 11 March 1996 on the legal | ||
protection of databases, and under any national implementation thereof, | ||
including any amended or successor version of such directive); and | ||
7. other similar, equivalent or corresponding rights throughout the world | ||
based on applicable law or treaty, and any national implementations | ||
thereof. | ||
@@ -88,21 +88,21 @@ 2. Waiver. To the greatest extent permitted by, but not in contravention of, | ||
4. Limitations and Disclaimers. | ||
1. No trademark or patent rights held by Affirmer are waived, abandoned, | ||
surrendered, licensed or otherwise affected by this document. | ||
2. Affirmer offers the Work as-is and makes no representations or | ||
warranties of any kind concerning the Work, express, implied, statutory | ||
or otherwise, including without limitation warranties of title, | ||
merchantability, fitness for a particular purpose, non infringement, or | ||
the absence of latent or other defects, accuracy, or the present or | ||
absence of errors, whether or not discoverable, all to the greatest | ||
extent permissible under applicable law. | ||
3. Affirmer disclaims responsibility for clearing rights of other persons | ||
that may apply to the Work or any use thereof, including without | ||
limitation any person’s Copyright and Related Rights in the Work. | ||
Further, Affirmer disclaims responsibility for obtaining any necessary | ||
consents, permissions or other rights required for any use of the Work. | ||
4. Affirmer understands and acknowledges that Creative Commons is not a | ||
party to this document and has no duty or obligation with respect to | ||
this CC0 or use of the Work. | ||
1. No trademark or patent rights held by Affirmer are waived, abandoned, | ||
surrendered, licensed or otherwise affected by this document. | ||
2. Affirmer offers the Work as-is and makes no representations or | ||
warranties of any kind concerning the Work, express, implied, statutory | ||
or otherwise, including without limitation warranties of title, | ||
merchantability, fitness for a particular purpose, non infringement, or | ||
the absence of latent or other defects, accuracy, or the present or | ||
absence of errors, whether or not discoverable, all to the greatest | ||
extent permissible under applicable law. | ||
3. Affirmer disclaims responsibility for clearing rights of other persons | ||
that may apply to the Work or any use thereof, including without | ||
limitation any person’s Copyright and Related Rights in the Work. | ||
Further, Affirmer disclaims responsibility for obtaining any necessary | ||
consents, permissions or other rights required for any use of the Work. | ||
4. Affirmer understands and acknowledges that Creative Commons is not a | ||
party to this document and has no duty or obligation with respect to | ||
this CC0 or use of the Work. | ||
For more information, please see | ||
http://creativecommons.org/publicdomain/zero/1.0/. |
{ | ||
"name": "postcss-nesting", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Nest style and media rules inside each another, following the CSS Nesting Module Level 3 specification", | ||
@@ -5,0 +5,0 @@ "author": "Jonathan Neal <jonathantneal@hotmail.com>", |
19741
167