Skip to content

Commit 428147b

Browse files
committed
Use LF line endings
1 parent 8e2946a commit 428147b

File tree

108 files changed

+3401
-3394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+3401
-3394
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ npm-debug.log
33

44
playground/node_modules/
55
playground/jspm_packages/
6-
todo.md
6+
todo.md

CHANGELOG.md

+111-111
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,111 @@
1-
2-
# v0.9.0 - 2018-6-26
3-
4-
- Adds `opts.preserveInjectedVariables`, which when set to `false`, removes the `:root { ... }` custom property declarations added via `opts.variables`
5-
- Thank you to [@akdetrick](https://github.com/akdetrick) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/74)
6-
7-
8-
# v0.8.1 - 2018-3-21
9-
10-
- Log `undefined` variables (available in `result.warnings()`)
11-
- Thank you to [@pixeldrew](https://github.com/pixeldrew) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/69)
12-
13-
14-
# v0.8.0 - 2017-8-8
15-
16-
- Remove PostCSS `moveTo`/`append` deprecation warnings, [#50](https://github.com/MadLittleMods/postcss-css-variables/issues/50)
17-
- Thank you to [@modosc](https://github.com/modosc) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/56)
18-
19-
20-
# v0.7.0 - 2017-3-12
21-
22-
- Resolve `var` usage in fallbacks, [#37](https://github.com/MadLittleMods/postcss-css-variables/issues/37)
23-
- Thank you to [@asvny](https://github.com/asvny) and [@marklu](https://github.com/marklu) for the contribution, [#39](https://github.com/MadLittleMods/postcss-css-variables/issues/39) -> [#49](https://github.com/MadLittleMods/postcss-css-variables/pull/49)
24-
25-
26-
# v0.6.0 - 2016-9-23
27-
28-
- Update/refactor readme
29-
- Thank you to [@isiahmeadows](github.com/isiahmeadows) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/36)
30-
- Use string value for `undefined` variables to play nice with other plugins downstream
31-
- Thank you to [@vincentorback](github.com/vincentorback) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/44)
32-
33-
34-
# v0.5.2 - 2016-8-24
35-
36-
- Fix [#42](https://github.com/MadLittleMods/postcss-css-variables/issues/42) where `opts.preserve` was not working inside at-rules
37-
- Thank you to [@muftiev](github.com/muftiev) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/43)
38-
39-
40-
# v0.5.1 - 2015-10-24
41-
42-
- Fix [postcss/postcss#611](https://github.com/postcss/postcss/issues/611) where we were trying to remove the root node on clean up
43-
- Improved test setup
44-
45-
# v0.5.0 - 2015-9-12
46-
47-
- Upgrade to PostCSS v5. Fix [#20](https://github.com/MadLittleMods/postcss-css-variables/issues/20)
48-
49-
# v0.4.0 - 2015-7-2
50-
51-
- Fix [#15](https://github.com/MadLittleMods/postcss-css-variables/issues/15)
52-
- Remove slowness from cloning the `root` with `node.clone().removeAll()`. Now using `./lib/shallow-clone-node.js` to avoid cloning children which will get removed right after.
53-
- Thank you to [@ddprrt](https://github.com/ddprrt) for bringing up the slowness issue in this article, [PostCSS misconceptions](https://medium.com/@ddprrt/postcss-misconceptions-faf5dc5038df).
54-
55-
56-
57-
# v0.3.9 - 2015-6-29
58-
59-
- Remove `opts` global leak. Fix [#13](https://github.com/MadLittleMods/postcss-css-variables/issues/13)
60-
61-
62-
# v0.3.8 - 2015-5-28
63-
64-
- Add support for pseudo selectors `:hover` `:before`
65-
66-
# v0.3.7 - 2015-5-27
67-
68-
- Fix [#7](https://github.com/MadLittleMods/postcss-css-variables/issues/7): Support for child combinator
69-
- Added tests for child-combinator/direct-descendant coverage
70-
71-
# v0.3.6 - 2015-5-21
72-
73-
- Fix [#6](https://github.com/MadLittleMods/postcss-css-variables/issues/6). Variable usage in comma separated selector to use proper scope
74-
75-
# v0.3.5 - 2015-5-12
76-
77-
- Big refactor of code to reduce cyclomatic complexity. Still needs work though.
78-
- Fix variable referencing another variable resolution when being changed by at-rule in non-root rule
79-
80-
# v0.3.4 - 2015-5-12
81-
82-
- Fix variable referencing another variable resolution when being changed by at-rule
83-
84-
# v0.3.3 - 2015-5-11
85-
86-
- Add support for last piece of combinator chain in selector resolution matching.
87-
- `.foo + .bar` can match variables declared in `.bar`
88-
89-
# v0.3.1 - 2015-5-5
90-
91-
- Large overhaul of code to make it more robust on proper scope resolution.
92-
- Fix [#2]](https://github.com/MadLittleMods/postcss-css-variables/issues/2)
93-
94-
# v0.2.3 - 2015-5-4
95-
96-
- Add support for CSS4 descendant selector `>>` syntax
97-
98-
# v0.2.2 - 2015-5-1
99-
100-
- Automatically prefix any variables defined in `options.variables` with `--` (according to CSS custom property syntax).
101-
102-
# v0.2.1 - 2015-4-30
103-
104-
- Added support for descendant selector nesting instead of just physical space nesting
105-
- Fixed issue with comma separated rules. It was throwing a undefined is not a function error
106-
- Moved to external scope check `isUnderScope` instead of integrated into `resolveValue`
107-
- Added test for empty `var()` call. See [test/fixtures/empty-var-func.css](https://github.com/MadLittleMods/postcss-css-variables/blob/master/test/fixtures/empty-var-func.css)
108-
109-
# v0.1.0 - 2015-4-29
110-
111-
- First release
1+
2+
# v0.9.0 - 2018-6-26
3+
4+
- Adds `opts.preserveInjectedVariables`, which when set to `false`, removes the `:root { ... }` custom property declarations added via `opts.variables`
5+
- Thank you to [@akdetrick](https://github.com/akdetrick) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/74)
6+
7+
8+
# v0.8.1 - 2018-3-21
9+
10+
- Log `undefined` variables (available in `result.warnings()`)
11+
- Thank you to [@pixeldrew](https://github.com/pixeldrew) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/69)
12+
13+
14+
# v0.8.0 - 2017-8-8
15+
16+
- Remove PostCSS `moveTo`/`append` deprecation warnings, [#50](https://github.com/MadLittleMods/postcss-css-variables/issues/50)
17+
- Thank you to [@modosc](https://github.com/modosc) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/56)
18+
19+
20+
# v0.7.0 - 2017-3-12
21+
22+
- Resolve `var` usage in fallbacks, [#37](https://github.com/MadLittleMods/postcss-css-variables/issues/37)
23+
- Thank you to [@asvny](https://github.com/asvny) and [@marklu](https://github.com/marklu) for the contribution, [#39](https://github.com/MadLittleMods/postcss-css-variables/issues/39) -> [#49](https://github.com/MadLittleMods/postcss-css-variables/pull/49)
24+
25+
26+
# v0.6.0 - 2016-9-23
27+
28+
- Update/refactor readme
29+
- Thank you to [@isiahmeadows](github.com/isiahmeadows) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/36)
30+
- Use string value for `undefined` variables to play nice with other plugins downstream
31+
- Thank you to [@vincentorback](github.com/vincentorback) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/44)
32+
33+
34+
# v0.5.2 - 2016-8-24
35+
36+
- Fix [#42](https://github.com/MadLittleMods/postcss-css-variables/issues/42) where `opts.preserve` was not working inside at-rules
37+
- Thank you to [@muftiev](github.com/muftiev) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/43)
38+
39+
40+
# v0.5.1 - 2015-10-24
41+
42+
- Fix [postcss/postcss#611](https://github.com/postcss/postcss/issues/611) where we were trying to remove the root node on clean up
43+
- Improved test setup
44+
45+
# v0.5.0 - 2015-9-12
46+
47+
- Upgrade to PostCSS v5. Fix [#20](https://github.com/MadLittleMods/postcss-css-variables/issues/20)
48+
49+
# v0.4.0 - 2015-7-2
50+
51+
- Fix [#15](https://github.com/MadLittleMods/postcss-css-variables/issues/15)
52+
- Remove slowness from cloning the `root` with `node.clone().removeAll()`. Now using `./lib/shallow-clone-node.js` to avoid cloning children which will get removed right after.
53+
- Thank you to [@ddprrt](https://github.com/ddprrt) for bringing up the slowness issue in this article, [PostCSS misconceptions](https://medium.com/@ddprrt/postcss-misconceptions-faf5dc5038df).
54+
55+
56+
57+
# v0.3.9 - 2015-6-29
58+
59+
- Remove `opts` global leak. Fix [#13](https://github.com/MadLittleMods/postcss-css-variables/issues/13)
60+
61+
62+
# v0.3.8 - 2015-5-28
63+
64+
- Add support for pseudo selectors `:hover` `:before`
65+
66+
# v0.3.7 - 2015-5-27
67+
68+
- Fix [#7](https://github.com/MadLittleMods/postcss-css-variables/issues/7): Support for child combinator
69+
- Added tests for child-combinator/direct-descendant coverage
70+
71+
# v0.3.6 - 2015-5-21
72+
73+
- Fix [#6](https://github.com/MadLittleMods/postcss-css-variables/issues/6). Variable usage in comma separated selector to use proper scope
74+
75+
# v0.3.5 - 2015-5-12
76+
77+
- Big refactor of code to reduce cyclomatic complexity. Still needs work though.
78+
- Fix variable referencing another variable resolution when being changed by at-rule in non-root rule
79+
80+
# v0.3.4 - 2015-5-12
81+
82+
- Fix variable referencing another variable resolution when being changed by at-rule
83+
84+
# v0.3.3 - 2015-5-11
85+
86+
- Add support for last piece of combinator chain in selector resolution matching.
87+
- `.foo + .bar` can match variables declared in `.bar`
88+
89+
# v0.3.1 - 2015-5-5
90+
91+
- Large overhaul of code to make it more robust on proper scope resolution.
92+
- Fix [#2]](https://github.com/MadLittleMods/postcss-css-variables/issues/2)
93+
94+
# v0.2.3 - 2015-5-4
95+
96+
- Add support for CSS4 descendant selector `>>` syntax
97+
98+
# v0.2.2 - 2015-5-1
99+
100+
- Automatically prefix any variables defined in `options.variables` with `--` (according to CSS custom property syntax).
101+
102+
# v0.2.1 - 2015-4-30
103+
104+
- Added support for descendant selector nesting instead of just physical space nesting
105+
- Fixed issue with comma separated rules. It was throwing a undefined is not a function error
106+
- Moved to external scope check `isUnderScope` instead of integrated into `resolveValue`
107+
- Added test for empty `var()` call. See [test/fixtures/empty-var-func.css](https://github.com/MadLittleMods/postcss-css-variables/blob/master/test/fixtures/empty-var-func.css)
108+
109+
# v0.1.0 - 2015-4-29
110+
111+
- First release

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ module.exports = postcss.plugin('postcss-css-variables', function(options) {
151151
// Collect all of the variables defined
152152
// ---------------------------------------------------------
153153
// ---------------------------------------------------------
154+
//console.log('Collecting variables defined START');
154155
eachCssVariableDeclaration(css, function(decl) {
155156
var declParentRule = decl.parent;
156157

@@ -195,6 +196,7 @@ module.exports = postcss.plugin('postcss-css-variables', function(options) {
195196
nodesToRemoveAtEnd.push(declParentRule);
196197
}
197198
});
199+
//console.log('Collecting variables defined END');
198200

199201

200202

+67-67
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
1-
2-
var shallowCloneNode = require('./shallow-clone-node');
3-
4-
// Splice on a parent scope onto a node
5-
// And return a detached clone
6-
var cloneSpliceParentOntoNodeWhen = function(node, parent, /*optional*/whenCb) {
7-
whenCb = whenCb || function() {
8-
return true;
9-
};
10-
11-
var cloneList = [];
12-
13-
// Gather node ancestors and clone along the way
14-
var current = node;
15-
var isWhenNow = false;
16-
while(current && !isWhenNow) {
17-
if(current.type === 'decl') {
18-
cloneList.push(current.clone());
19-
}
20-
else {
21-
cloneList.push(shallowCloneNode(current));
22-
}
23-
24-
isWhenNow = whenCb(current);
25-
current = current.parent;
26-
}
27-
28-
29-
// Gather parent ancestors all the way up and clone along the way
30-
// The list goes from lowest to highest ancestor
31-
var cloneParentList = [];
32-
var currentParent = parent;
33-
while(currentParent) {
34-
cloneParentList.push(shallowCloneNode(currentParent));
35-
36-
currentParent = currentParent.parent;
37-
}
38-
// Assign parents to our parent clones
39-
cloneParentList.forEach(function(parentClone, index, cloneParentList) {
40-
// Keep assigning parents detached until just very end
41-
if(index + 1 < cloneParentList.length) {
42-
//parentClone.moveTo(cloneParentList[index+1]);
43-
parentClone.parent = cloneParentList[index + 1];
44-
}
45-
});
46-
47-
48-
// Assign parents to our node clones
49-
cloneList.forEach(function(clone, index, cloneList) {
50-
// Keep assigning parents detached until just very end
51-
if(index + 1 < cloneList.length) {
52-
//clone.moveTo(cloneList[index+1]);
53-
clone.parent = cloneList[index + 1];
54-
// Then splice on the new parent scope
55-
} else {
56-
// Set the highest parent ancestor to back to where we should splice in
57-
cloneParentList.slice(-1)[0].parent = current;
58-
// Set the node clone to the lowest parent ancestor to finish off the splice
59-
//clone.moveTo(cloneParentList[0]);
60-
clone.parent = cloneParentList[0];
61-
}
62-
});
63-
64-
return cloneList[0];
65-
};
66-
67-
module.exports = cloneSpliceParentOntoNodeWhen;
1+
2+
var shallowCloneNode = require('./shallow-clone-node');
3+
4+
// Splice on a parent scope onto a node
5+
// And return a detached clone
6+
var cloneSpliceParentOntoNodeWhen = function(node, parent, /*optional*/whenCb) {
7+
whenCb = whenCb || function() {
8+
return true;
9+
};
10+
11+
var cloneList = [];
12+
13+
// Gather node ancestors and clone along the way
14+
var current = node;
15+
var isWhenNow = false;
16+
while(current && !isWhenNow) {
17+
if(current.type === 'decl') {
18+
cloneList.push(current.clone());
19+
}
20+
else {
21+
cloneList.push(shallowCloneNode(current));
22+
}
23+
24+
isWhenNow = whenCb(current);
25+
current = current.parent;
26+
}
27+
28+
29+
// Gather parent ancestors all the way up and clone along the way
30+
// The list goes from lowest to highest ancestor
31+
var cloneParentList = [];
32+
var currentParent = parent;
33+
while(currentParent) {
34+
cloneParentList.push(shallowCloneNode(currentParent));
35+
36+
currentParent = currentParent.parent;
37+
}
38+
// Assign parents to our parent clones
39+
cloneParentList.forEach(function(parentClone, index, cloneParentList) {
40+
// Keep assigning parents detached until just very end
41+
if(index + 1 < cloneParentList.length) {
42+
//parentClone.moveTo(cloneParentList[index+1]);
43+
parentClone.parent = cloneParentList[index + 1];
44+
}
45+
});
46+
47+
48+
// Assign parents to our node clones
49+
cloneList.forEach(function(clone, index, cloneList) {
50+
// Keep assigning parents detached until just very end
51+
if(index + 1 < cloneList.length) {
52+
//clone.moveTo(cloneList[index+1]);
53+
clone.parent = cloneList[index + 1];
54+
// Then splice on the new parent scope
55+
} else {
56+
// Set the highest parent ancestor to back to where we should splice in
57+
cloneParentList.slice(-1)[0].parent = current;
58+
// Set the node clone to the lowest parent ancestor to finish off the splice
59+
//clone.moveTo(cloneParentList[0]);
60+
clone.parent = cloneParentList[0];
61+
}
62+
});
63+
64+
return cloneList[0];
65+
};
66+
67+
module.exports = cloneSpliceParentOntoNodeWhen;

0 commit comments

Comments
 (0)