Skip to content

Commit a6a528b

Browse files
committed
Merge branch 'master' into readme-refactor
2 parents 5b2363f + 9cbef87 commit a6a528b

File tree

6 files changed

+62
-11
lines changed

6 files changed

+62
-11
lines changed

CHANGELOG.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11

2+
3+
# v0.5.2 - 2016-8-24
4+
5+
- Fix [#42](https://github.com/MadLittleMods/postcss-css-variables/issues/42) where `opts.preserve` was not working inside at-rules
6+
- Thank you to [@muftiev](github.com/muftiev) for the [contribution](https://github.com/MadLittleMods/postcss-css-variables/pull/43)
7+
8+
29
# v0.5.1 - 2015-10-24
310

411
- Fix [postcss/postcss#611](https://github.com/postcss/postcss/issues/611) where we were trying to remove the root node on clean up
512
- Improved test setup
613

714
# v0.5.0 - 2015-9-12
815

9-
- Upgrade to PostCSS v5. Fix #20
16+
- Upgrade to PostCSS v5. Fix [#20](https://github.com/MadLittleMods/postcss-css-variables/issues/20)
1017

1118
# v0.4.0 - 2015-7-2
1219

13-
- Fix #15
20+
- Fix [#15](https://github.com/MadLittleMods/postcss-css-variables/issues/15)
1421
- 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.
15-
- Thank you to @ddprrt for bringing up the slowness issue in this article, [PostCSS misconceptions](https://medium.com/@ddprrt/postcss-misconceptions-faf5dc5038df).
22+
- 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).
1623

1724

1825

1926
# v0.3.9 - 2015-6-29
2027

21-
- Remove `opts` global leak. Fix #13
28+
- Remove `opts` global leak. Fix [#13](https://github.com/MadLittleMods/postcss-css-variables/issues/13)
2229

2330

2431
# v0.3.8 - 2015-5-28
@@ -27,12 +34,12 @@
2734

2835
# v0.3.7 - 2015-5-27
2936

30-
- Fix #7: Support for child combinator
37+
- Fix [#7](https://github.com/MadLittleMods/postcss-css-variables/issues/7): Support for child combinator
3138
- Added tests for child-combinator/direct-descendant coverage
3239

3340
# v0.3.6 - 2015-5-21
3441

35-
- Fix #6. Variable usage in comma separated selector to use proper scope
42+
- Fix [#6](https://github.com/MadLittleMods/postcss-css-variables/issues/6). Variable usage in comma separated selector to use proper scope
3643

3744
# v0.3.5 - 2015-5-12
3845

@@ -51,7 +58,7 @@
5158
# v0.3.1 - 2015-5-5
5259

5360
- Large overhaul of code to make it more robust on proper scope resolution.
54-
- Fix #2
61+
- Fix [#2]](https://github.com/MadLittleMods/postcss-css-variables/issues/2)
5562

5663
# v0.2.3 - 2015-5-4
5764

lib/resolve-decl.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,15 @@ function resolveDecl(decl, map, /*optional*/shouldPreserve, /*optional*/logResol
9494
eachMapItemDependencyOfDecl(valueResults.variablesUsed, map, decl, function(mimicDecl, mapItem) {
9595
var ruleClone = shallowCloneNode(decl.parent);
9696
var declClone = decl.clone();
97-
// No mangle resolve
98-
declClone.value = _logResolveValueResult(resolveValue(mimicDecl, map, true)).value;
99-
10097
// Add the declaration to our new rule
10198
ruleClone.append(declClone);
10299

100+
if(shouldPreserve === true) {
101+
declClone.cloneAfter();
102+
}
103+
104+
// No mangle resolve
105+
declClone.value = _logResolveValueResult(resolveValue(mimicDecl, map, true)).value;
103106

104107
if(mapItem.isUnderAtRule) {
105108
// Create the clean atRule for which we place the declaration under

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcss-css-variables",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"description": "PostCSS plugin to transform CSS Custom Properties(CSS variables) syntax into a static representation",
55
"keywords": [
66
"postcss",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
:root {
2+
--width: 100px;
3+
}
4+
5+
@media (max-width: 1000px) {
6+
:root {
7+
--width: 200px;
8+
}
9+
}
10+
11+
.box {
12+
width: var(--width);
13+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
:root {
2+
--width: 100px;
3+
}
4+
5+
@media (max-width: 1000px) {
6+
:root {
7+
--width: 200px;
8+
}
9+
}
10+
11+
.box {
12+
width: 100px;
13+
width: var(--width);
14+
}
15+
16+
@media (max-width: 1000px) {
17+
18+
.box {
19+
width: 200px;
20+
width: var(--width);
21+
}
22+
}

test/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ describe('postcss-css-variables', function() {
169169
{ preserve: true }
170170
);
171171

172+
test(
173+
'preserves variables in @media when `preserve` is `true`',
174+
'preserve-variables-in-media',
175+
{ preserve: true }
176+
);
177+
172178
test(
173179
'preserves computed value when `preserve` is `\'computed\'`',
174180
'preserve-computed',

0 commit comments

Comments
 (0)