Skip to content

Commit

Permalink
Always use complexSelector transformer
Browse files Browse the repository at this point in the history
Added tests for a list of complex selectors.
  • Loading branch information
dfreedm committed Oct 17, 2017
1 parent ad7805e commit feaf5c6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/lib/style-transformer.html
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 14 additions & 4 deletions test/unit/custom-style-transformed.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
color: rgb(123, 123, 123);
border: 10px solid black;
}
html, body:not([foo]) * {
padding-left: 10px;
}
</style>
</body>
<dom-module id="x-styled">
Expand All @@ -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');
});
})
</script>

0 comments on commit feaf5c6

Please sign in to comment.