Skip to content

Commit 453eccc

Browse files
authored
Merge pull request #3748 from Polymer/host-non-paren
re-support selectors like `:host[inline]` since this was previously s…
2 parents 645bcd0 + e770343 commit 453eccc

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/lib/style-transformer.html

+20-10
Original file line numberDiff line numberDiff line change
@@ -237,19 +237,29 @@
237237
_transformHostSelector: function(selector, hostScope) {
238238
var m = selector.match(HOST_PAREN);
239239
var paren = m && m[2].trim() || '';
240-
if (paren && !paren[0].match(SIMPLE_SELECTOR_PREFIX)) {
241-
// paren starts with a type selector
242-
var typeSelector = paren.split(SIMPLE_SELECTOR_PREFIX)[0];
243-
// if the type selector is our hostScope then avoid pre-pending it
244-
if (typeSelector === hostScope) {
245-
return paren;
246-
// otherwise, this selector should not match in this scope so
247-
// output a bogus selector.
240+
if (paren) {
241+
if (!paren[0].match(SIMPLE_SELECTOR_PREFIX)) {
242+
// paren starts with a type selector
243+
var typeSelector = paren.split(SIMPLE_SELECTOR_PREFIX)[0];
244+
// if the type selector is our hostScope then avoid pre-pending it
245+
if (typeSelector === hostScope) {
246+
return paren;
247+
// otherwise, this selector should not match in this scope so
248+
// output a bogus selector.
249+
} else {
250+
return SELECTOR_NO_MATCH;
251+
}
248252
} else {
249-
return SELECTOR_NO_MATCH;
253+
return hostScope + paren;
250254
}
255+
// if no paren, do a straight :host replacement.
256+
// TODO(sorvell): this should not strictly be necessary but
257+
// it's needed to maintain support for `:host[foo]` type selectors
258+
// which have been improperly used under Shady DOM. This should be
259+
// deprecated.
260+
} else {
261+
return selector.replace(HOST, hostScope);
251262
}
252-
return hostScope + paren;
253263
},
254264

255265
documentRule: function(rule) {

0 commit comments

Comments
 (0)