Permalink
Browse files

Fixed: trailing space after custom property name causes duplicate emp…

…ty property (#43)

* Fix issue where trailing space causes duplicate empty property when using `var()`.

* Adding test for trailing space.
  • Loading branch information...
1 parent 136250a commit 5366045b7ac9d7a16c2b83489b4fbf2d58c522b7 @ryanfitzer ryanfitzer committed with MoOx Apr 22, 2016
View
@@ -12,7 +12,7 @@ var balanced = require("balanced-match")
var VAR_PROP_IDENTIFIER = "--"
var VAR_FUNC_IDENTIFIER = "var"
// matches `name[, fallback]`, captures "name" and "fallback"
-var RE_VAR = /([\w-]+)(?:\s*,\s*)?(.*)?/
+var RE_VAR = /([\w-]+)(?:\s*,\s*)?\s*(.*)?/
/**
* Resolve CSS variables in a value
@@ -0,0 +1,7 @@
+:root {
+ --test-trailing-space: red;
+}
+
+div {
+ color: var( --test-trailing-space );
+}
@@ -0,0 +1,3 @@
+div {
+ color: red;
+}
View
@@ -228,3 +228,8 @@ test("strict option", function(t) {
t.end()
})
+
+test("ignores trailing space after variable", function(t) {
+ compareFixtures(t, "substitution-trailing-space")
+ t.end()
+})

0 comments on commit 5366045

Please sign in to comment.