Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Commit

Permalink
Added: JS defined variables are now resolved too (3.2.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoOx committed Mar 31, 2015
1 parent 78e550e commit a5aa2bf
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.2.0 - 2015-03-31

- Added: JS defined variables are now resolved too ([#22](https://github.com/postcss/postcss-custom-properties/issues/22))

# 3.1.0 - 2015-03-16

- Added: variables defined in JS are now automatically prefixed with `--`
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module.exports = function(options) {

// apply js-defined custom properties
Object.keys(variables).forEach(function(variable) {
map[variable] = variables[variable]
map[variable] = resolveValue(variables[variable], map)
})

// resolve variables
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-custom-properties",
"version": "3.1.0",
"version": "3.2.0",
"description": "PostCSS plugin to polyfill W3C CSS Custom Properties for cascading variables",
"keywords": [
"css",
Expand Down
8 changes: 5 additions & 3 deletions test/fixtures/js-defined.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
}

div {
color: var(--test-one);
color: var(--test-two);
color: var(--test-three);
p: var(--test-one);
p: var(--test-two);
p: var(--test-three);
p: var(--test-varception);
p: var(--test-jsception);
}
8 changes: 5 additions & 3 deletions test/fixtures/js-defined.expected.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
div {
color: js-one;
color: js-two;
color: js-three;
p: js-one;
p: js-two;
p: js-three;
p: js-one;
p: js-one;
}
2 changes: 2 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ test("accepts variables defined from JavaScript, and overrides local definitions
"--test-one": "js-one",
"--test-two": "js-two",
"--test-three": "js-three",
"--test-varception": "var(--test-one)",
"--test-jsception": "var(--test-varception)",
},
})
t.end()
Expand Down

0 comments on commit a5aa2bf

Please sign in to comment.