Skip to content

Commit ad7805e

Browse files
committed
Check that document selectors are actually simple selectors
Checking for `/deep/` and `::shadow` is not enough Fixes #4885
1 parent 5c0df2d commit ad7805e

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

src/lib/style-transformer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@
311311
},
312312

313313
_transformDocumentSelector: function(selector) {
314-
return selector.match(SCOPE_JUMP) ?
314+
return (selector.match(SCOPE_JUMP) || selector.match(SIMPLE_SELECTOR_SEP) )?
315315
this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR) :
316316
this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELECTOR);
317317
},

test/runner.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@
9898
'unit/dir.html',
9999
'unit/dir.html?dom=shadow',
100100
'unit/dir.html?lazyRegister=true&useNativeCSSProperties=true',
101-
'unit/dir.html?lazyRegister=true&useNativeCSSProperties=true&dom=shadow'
101+
'unit/dir.html?lazyRegister=true&useNativeCSSProperties=true&dom=shadow',
102+
'unit/custom-style-transformed.html',
103+
'unit/custom-style-transformed.html?dom=shadow',
104+
'unit/custom-style-transformed.html?lazyRegister=true&useNativeCSSProperties=true',
105+
'unit/custom-style-transformed.html?lazyRegister=true&useNativeCSSProperties=true&dom=shadow'
102106
];
103107

104108
if (window.customElements || document.registerElement) {
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!doctype html>
2+
<!--
3+
@license
4+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
5+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8+
Code distributed by Google as part of the polymer project is also
9+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10+
-->
11+
<html>
12+
<head>
13+
<meta charset="utf-8">
14+
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
15+
<script src="../../../web-component-tester/browser.js"></script>
16+
<link rel="import" href="../../polymer.html">
17+
</head>
18+
<body>
19+
<style is="custom-style">
20+
html:not([foo]) * {
21+
color: rgb(123, 123, 123);
22+
border: 10px solid black;
23+
}
24+
</style>
25+
</body>
26+
<dom-module id="x-styled">
27+
<template>
28+
<style>
29+
:host {
30+
display: block;
31+
}
32+
</style>
33+
<div id="target"></div>
34+
</template>
35+
</dom-module>
36+
37+
<x-styled id="target"></x-styled>
38+
39+
<script>
40+
HTMLImports.whenReady(function() {
41+
Polymer({is: 'x-styled'});
42+
});
43+
suite('complicated custom style', function() {
44+
test('complicated selector', function() {
45+
var el = document.querySelector('x-styled#target');
46+
var target = el.$.target;
47+
assert.equal(getComputedStyle(el).getPropertyValue('border-top-width').trim(), '10px');
48+
assert.equal(getComputedStyle(target).getPropertyValue('border-top-width').trim(), '0px');
49+
assert.equal(getComputedStyle(target).getPropertyValue('color').trim(), 'rgb(123, 123, 123)');
50+
})
51+
})
52+
</script>

0 commit comments

Comments
 (0)