Skip to content

Commit 63376cb

Browse files
authored
Merge pull request #4886 from Polymer/document-selector-fix
Check that document selectors are actually simple selectors
2 parents 5c0df2d + feaf5c6 commit 63376cb

File tree

3 files changed

+68
-4
lines changed

3 files changed

+68
-4
lines changed

src/lib/style-transformer.html

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

313313
_transformDocumentSelector: function(selector) {
314-
return selector.match(SCOPE_JUMP) ?
315-
this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR) :
316-
this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELECTOR);
314+
return this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR);
317315
},
318316

319317
// For forward compatibility with ShadowDOM v1 and Polymer 2.x,

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: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
html, body:not([foo]) * {
25+
padding-left: 10px;
26+
}
27+
</style>
28+
</body>
29+
<dom-module id="x-styled">
30+
<template>
31+
<style>
32+
:host {
33+
display: block;
34+
}
35+
</style>
36+
<div id="target"></div>
37+
</template>
38+
</dom-module>
39+
40+
<x-styled id="target"></x-styled>
41+
42+
<script>
43+
HTMLImports.whenReady(function() {
44+
Polymer({is: 'x-styled'});
45+
});
46+
suite('complicated custom style', function() {
47+
var el, target;
48+
suiteSetup(function() {
49+
el = document.querySelector('x-styled#target');
50+
target = el.$.target;
51+
});
52+
test('complex selector', function() {
53+
assert.equal(getComputedStyle(el).getPropertyValue('border-top-width').trim(), '10px');
54+
assert.equal(getComputedStyle(target).getPropertyValue('border-top-width').trim(), '0px');
55+
assert.equal(getComputedStyle(target).getPropertyValue('color').trim(), 'rgb(123, 123, 123)');
56+
});
57+
test('list of complex selectors', function() {
58+
assert.equal(getComputedStyle(el).getPropertyValue('padding-left').trim(), '10px');
59+
assert.equal(getComputedStyle(target).getPropertyValue('padding-left').trim(), '0px');
60+
});
61+
})
62+
</script>

0 commit comments

Comments
 (0)