From feaf5c6106fce875733c60a5ceb6509c5bd60217 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Tue, 17 Oct 2017 10:38:49 -0700 Subject: [PATCH] Always use complexSelector transformer Added tests for a list of complex selectors. --- src/lib/style-transformer.html | 4 +--- test/unit/custom-style-transformed.html | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/lib/style-transformer.html b/src/lib/style-transformer.html index caf8ddd710..94775b5589 100644 --- a/src/lib/style-transformer.html +++ b/src/lib/style-transformer.html @@ -311,9 +311,7 @@ }, _transformDocumentSelector: function(selector) { - return (selector.match(SCOPE_JUMP) || selector.match(SIMPLE_SELECTOR_SEP) )? - this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR) : - this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELECTOR); + return this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR); }, // For forward compatibility with ShadowDOM v1 and Polymer 2.x, diff --git a/test/unit/custom-style-transformed.html b/test/unit/custom-style-transformed.html index 88de82cd79..e0b064c580 100644 --- a/test/unit/custom-style-transformed.html +++ b/test/unit/custom-style-transformed.html @@ -21,6 +21,9 @@ color: rgb(123, 123, 123); border: 10px solid black; } + html, body:not([foo]) * { + padding-left: 10px; + } @@ -41,12 +44,19 @@ Polymer({is: 'x-styled'}); }); suite('complicated custom style', function() { - test('complicated selector', function() { - var el = document.querySelector('x-styled#target'); - var target = el.$.target; + var el, target; + suiteSetup(function() { + el = document.querySelector('x-styled#target'); + target = el.$.target; + }); + test('complex selector', function() { assert.equal(getComputedStyle(el).getPropertyValue('border-top-width').trim(), '10px'); assert.equal(getComputedStyle(target).getPropertyValue('border-top-width').trim(), '0px'); assert.equal(getComputedStyle(target).getPropertyValue('color').trim(), 'rgb(123, 123, 123)'); - }) + }); + test('list of complex selectors', function() { + assert.equal(getComputedStyle(el).getPropertyValue('padding-left').trim(), '10px'); + assert.equal(getComputedStyle(target).getPropertyValue('padding-left').trim(), '0px'); + }); }) \ No newline at end of file