postcss-nested 2.1.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +1 -1
- package/index.js +17 -6
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
3
3
|
|
|
4
|
+
## 3.0
|
|
5
|
+
* Add `@font-face` to bubbling at-rules (by Valeriy Komlev).
|
|
6
|
+
* Add special logic for `@font-face` bubbling (by Phanindra Pydisetty).
|
|
7
|
+
* Use PostCSS selector parser 3.0.
|
|
8
|
+
|
|
4
9
|
## 2.1.2
|
|
5
10
|
* Fix replacing multiple `&`.
|
|
6
11
|
|
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ See [PostCSS] docs for examples for your environment.
|
|
|
74
74
|
|
|
75
75
|
### `bubble`
|
|
76
76
|
|
|
77
|
-
By default, plugin will unwrap only `@media`, `@supports` and `@document
|
|
77
|
+
By default, plugin will unwrap only `@media`, `@supports`, `@font-face` and `@document
|
|
78
78
|
at-rules. You can add your custom at-rules to this list by `bubble` option:
|
|
79
79
|
|
|
80
80
|
```js
|
package/index.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
var postcss = require('postcss');
|
|
2
2
|
var parser = require('postcss-selector-parser');
|
|
3
3
|
|
|
4
|
+
function parse(str) {
|
|
5
|
+
var nodes;
|
|
6
|
+
var saver = parser(function (parsed) {
|
|
7
|
+
nodes = parsed;
|
|
8
|
+
});
|
|
9
|
+
saver.processSync(str);
|
|
10
|
+
return nodes.at(0);
|
|
11
|
+
}
|
|
12
|
+
|
|
4
13
|
function replace(nodes, parent) {
|
|
5
14
|
var replaced = false;
|
|
6
|
-
nodes.
|
|
15
|
+
nodes.each(function (i) {
|
|
7
16
|
if (i.type === 'nesting') {
|
|
8
17
|
i.replaceWith(parent.clone());
|
|
9
18
|
replaced = true;
|
|
10
19
|
} else if (i.nodes) {
|
|
11
|
-
if (replace(i
|
|
20
|
+
if (replace(i, parent)) {
|
|
12
21
|
replaced = true;
|
|
13
22
|
}
|
|
14
23
|
}
|
|
@@ -19,11 +28,11 @@ function replace(nodes, parent) {
|
|
|
19
28
|
function selectors(parent, child) {
|
|
20
29
|
var result = [];
|
|
21
30
|
parent.selectors.forEach(function (i) {
|
|
22
|
-
var parentNode =
|
|
31
|
+
var parentNode = parse(i);
|
|
23
32
|
|
|
24
33
|
child.selectors.forEach(function (j) {
|
|
25
|
-
var node =
|
|
26
|
-
var replaced = replace(node
|
|
34
|
+
var node = parse(j);
|
|
35
|
+
var replaced = replace(node, parentNode);
|
|
27
36
|
if (!replaced) {
|
|
28
37
|
node.prepend(parser.combinator({ value: ' ' }));
|
|
29
38
|
node.prepend(parentNode.clone());
|
|
@@ -56,6 +65,8 @@ function atruleChilds(rule, atrule) {
|
|
|
56
65
|
atruleChilds(rule, child);
|
|
57
66
|
}
|
|
58
67
|
});
|
|
68
|
+
if ( atrule.name === 'font-face' ) return;
|
|
69
|
+
|
|
59
70
|
if ( children.length ) {
|
|
60
71
|
var clone = rule.clone({ nodes: [] });
|
|
61
72
|
for ( var i = 0; i < children.length; i++ ) {
|
|
@@ -92,7 +103,7 @@ function processRule(rule, bubble, preserveEmpty) {
|
|
|
92
103
|
}
|
|
93
104
|
|
|
94
105
|
module.exports = postcss.plugin('postcss-nested', function (opts) {
|
|
95
|
-
var bubble = ['media', 'supports', 'document'];
|
|
106
|
+
var bubble = ['media', 'supports', 'document', 'font-face'];
|
|
96
107
|
if ( opts && opts.bubble ) {
|
|
97
108
|
bubble = bubble.concat(opts.bubble.map(function (i) {
|
|
98
109
|
return i.replace(/^@/, '');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-nested",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "PostCSS plugin to unwrap nested rules like how Sass does it.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postcss",
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": "postcss/postcss-nested",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"postcss": "^6.0.
|
|
17
|
-
"postcss-selector-parser": "^
|
|
16
|
+
"postcss": "^6.0.14",
|
|
17
|
+
"postcss-selector-parser": "^3.1.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"eslint": "^4.
|
|
20
|
+
"eslint": "^4.13.0",
|
|
21
|
+
"eslint-ci": "^0.1.1",
|
|
21
22
|
"eslint-config-postcss": "^2.0.2",
|
|
22
|
-
"jest": "^
|
|
23
|
+
"jest": "^21.2.1"
|
|
23
24
|
},
|
|
24
25
|
"jest": {
|
|
25
26
|
"coverageThreshold": {
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
}
|
|
30
31
|
},
|
|
31
32
|
"scripts": {
|
|
32
|
-
"test": "jest --coverage && eslint *.js"
|
|
33
|
+
"test": "jest --coverage && eslint-ci *.js"
|
|
33
34
|
},
|
|
34
35
|
"eslintConfig": {
|
|
35
36
|
"extends": "eslint-config-postcss/es5",
|