From 926d0e5274c2c9e0313e9d6c10d40858bf668069 Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Wed, 10 Feb 2016 23:33:48 +0100 Subject: [PATCH] Fix parsing of parenthesis in default of variable declaration --- src/lib/style-properties.html | 13 +++++++------ test/unit/styling-cross-scope-var.html | 13 +++++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/lib/style-properties.html b/src/lib/style-properties.html index 74436cdc..8f0fd3a8 100644 --- a/src/lib/style-properties.html +++ b/src/lib/style-properties.html @@ -160,12 +160,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN if (m) { p = this.valueForProperty(props[m[1]], props); } else { - var pp = p.split(':'); - if (pp[1]) { - pp[1] = pp[1].trim(); - pp[1] = this.valueForProperty(pp[1], props) || pp[1]; + var colon = p.indexOf(':'); + if (colon !== -1) { + var pp = p.substring(colon); + pp = pp.trim(); + pp = this.valueForProperty(pp, props) || pp; + p = p.substring(0, colon) + pp; } - p = pp.join(':'); } parts[i] = (p && p.lastIndexOf(';') === p.length - 1) ? // strip trailing ; @@ -449,7 +450,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN // var(--a, --b) // var(--a, fallback-literal) // var(--a, fallback-literal(with-one-nested-parentheses)) - VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,)]*)|(?:[^;]*\([^;)]*\)))[\s]*?\)/gi, + VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,()]*)|(?:[^;()]*\([^;)]*\)))[\s]*?\)/gi, VAR_CAPTURE: /\([\s]*(--[^,\s)]*)(?:,[\s]*(--[^,\s)]*))?(?:\)|,)/gi, ANIMATION_MATCH: /(animation\s*:)|(animation-name\s*:)/, IS_VAR: /^--/, diff --git a/test/unit/styling-cross-scope-var.html b/test/unit/styling-cross-scope-var.html index ffa55401..371345ac 100644 --- a/test/unit/styling-cross-scope-var.html +++ b/test/unit/styling-cross-scope-var.html @@ -445,6 +445,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN } #endTerm {border: var(--end-term)} + + #parenthesis { + background-image: var(--foo-background-image, url(http://placehold.it/400x300)); + }
x-scope
@@ -473,6 +477,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
new line var
end var
+
parenthesis