Skip to content

Commit

Permalink
Support :host > * as well
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Jul 19, 2017
1 parent 1d83b74 commit f3116fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/lib/style-transformer.html
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
// handle 2.x rules like `:host, html {}`
var parts = rule.selector.split(COMPLEX_SELECTOR_SEP);
parts = parts.filter(function(part) {
return part.trim() !== HOST;
return !part.match(HOST_OR_HOST_GT_STAR);
});
rule.selector = parts.join(COMPLEX_SELECTOR_SEP);
},
Expand Down Expand Up @@ -339,6 +339,7 @@
var CONTENT_START = new RegExp('^(' + CONTENT + ')');
var SELECTOR_NO_MATCH = 'should_not_match';
var SLOTTED_PAREN = /(?:::slotted)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;
var HOST_OR_HOST_GT_STAR = /:host(?:\s*>\s*\*)?/;

// exports
return api;
Expand Down
12 changes: 10 additions & 2 deletions test/unit/custom-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@
</style>
<style is="custom-style">
:host, html {
--polymer-2-root: 10px solid rgb(123, 123, 123);
--polymer-2-shared-host: 10px solid rgb(123, 123, 123);
}
:host > *, html {
--polymer-2-shared-host-gt-star: 5px dotted orange;
}
</style>
</head>
Expand Down Expand Up @@ -325,9 +328,13 @@
<template>
<style>
:host {
border: var(--polymer-2-root);
border: var(--polymer-2-shared-host);
}
#foo {
border: var(--polymer-2-shared-host-gt-star);
}
</style>
<div id="foo"></div>
</template>
</dom-module>

Expand Down Expand Up @@ -409,6 +416,7 @@
test('polymer 2 shared styles applied', function() {
var polymer2 = document.querySelector('polymer-2-root');
assertComputed(polymer2, '10px');
assertComputed(polymer2.$.foo, '5px');
})

test('custom properties registered as defaults', function() {
Expand Down

0 comments on commit f3116fd

Please sign in to comment.