From fd5778470551f677c2aa5827398681abb1994a88 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Thu, 29 Oct 2015 03:22:04 +0100 Subject: [PATCH] Fix for incorrect CSS selectors specificity as reported in #2531 Fix for overriding mixin properties, fixes #1873 Added awareness from `@apply()` position among other rules so that it is preserved after CSS variables/mixing substitution. `Polymer.StyleUtil.clearStyleRules()` method removed as it is not used anywhere. Some unused variables removed. Typos, unused variables and unnecessary escaping in regexps corrected. Tests added. --- src/lib/css-parse.html | 12 +-- src/lib/style-properties.html | 14 ++-- src/lib/style-transformer.html | 10 +-- src/lib/style-util.html | 5 -- src/standard/styling.html | 3 +- test/unit/css-parse.html | 3 +- test/unit/styling-remote.html | 4 +- test/unit/styling-scoped-elements.html | 100 ++++++++++++++++++++++++- test/unit/styling-scoped.html | 34 +++++++-- 9 files changed, 148 insertions(+), 37 deletions(-) diff --git a/src/lib/css-parse.html b/src/lib/css-parse.html index 2199fdb778..c3454b4d21 100644 --- a/src/lib/css-parse.html +++ b/src/lib/css-parse.html @@ -11,11 +11,11 @@ /* Extremely simple css parser. Intended to be not more than what we need - and definitely not necessarly correct =). + and definitely not necessarily correct =). */ Polymer.CssParse = (function() { - var api = { + return { // given a string of css, return a simple rule tree parse: function(text) { text = this._clean(text); @@ -31,7 +31,7 @@ _lex: function(text) { var root = {start: 0, end: text.length}; var n = root; - for (var i=0, s=0, l=text.length; i < l; i++) { + for (var i=0, l=text.length; i < l; i++) { switch (text[i]) { case this.OPEN_BRACE: //console.group(i); @@ -123,7 +123,7 @@ } } } - // emit rule iff there is cssText + // emit rule if there is cssText if (cssText) { if (node.selector) { text += node.selector + ' ' + this.OPEN_BRACE + '\n'; @@ -185,10 +185,6 @@ }; - - // exports - return api; - })(); diff --git a/src/lib/style-properties.html b/src/lib/style-properties.html index b007551bd5..df455af892 100644 --- a/src/lib/style-properties.html +++ b/src/lib/style-properties.html @@ -87,9 +87,7 @@ var parts = cssText.split(';'); for (var i=0, p; i .bar -> x-foo > .bar - * ::shadow, /deep/: processed simimlar to ::content + * ::shadow, /deep/: processed similar to ::content * :host-context(...): scopeName..., ... scopeName @@ -97,7 +97,7 @@ elementStyles: function(element, callback) { var styles = element._styles; var cssText = ''; - for (var i=0, l=styles.length, s, text; (i diff --git a/test/unit/styling-scoped-elements.html b/test/unit/styling-scoped-elements.html index 769f7ade21..673d6c75ce 100644 --- a/test/unit/styling-scoped-elements.html +++ b/test/unit/styling-scoped-elements.html @@ -286,7 +286,6 @@ })(); - + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unit/styling-scoped.html b/test/unit/styling-scoped.html index e445fa09d6..6f749beea2 100644 --- a/test/unit/styling-scoped.html +++ b/test/unit/styling-scoped.html @@ -43,6 +43,13 @@ [[dynamic]] + + +
+
+
+ +