Skip to content

Commit

Permalink
Restore functionality of selectors like :host(.foo)::after.
Browse files Browse the repository at this point in the history
Fixes #3749.
  • Loading branch information
Steven Orvell committed Jun 29, 2016
1 parent 453eccc commit ff88e17
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/lib/style-transformer.html
Expand Up @@ -250,7 +250,11 @@
return SELECTOR_NO_MATCH;
}
} else {
return hostScope + paren;
// make sure to do a replace here to catch selectors like:
// `:host(.foo)::before`
return selector.replace(HOST_PAREN, function(m, host, paren) {
return hostScope + paren;
});
}
// if no paren, do a straight :host replacement.
// TODO(sorvell): this should not strictly be necessary but
Expand Down
5 changes: 5 additions & 0 deletions test/unit/styling-scoped-elements.html
Expand Up @@ -133,6 +133,11 @@
border-width: 2px;
}

:host(.wide)::after {
content: 'a';
border: 4px solid blue;
};

#keyframes2.special {
--keyframes100: 200px;
}
Expand Down
7 changes: 5 additions & 2 deletions test/unit/styling-scoped.html
Expand Up @@ -58,8 +58,8 @@
<script>
suite('scoped-styling', function() {

function assertComputed(element, value, property) {
var computed = getComputedStyle(element);
function assertComputed(element, value, property, pseudo) {
var computed = getComputedStyle(element, pseudo);
property = property || 'border-top-width';
assert.equal(computed[property], value, 'computed style incorrect for ' + property);
}
Expand All @@ -73,6 +73,9 @@
test(':host, :host(...)', function() {
assertComputed(styled, '1px');
assertComputed(styledWide, '2px');
assertComputed(styled, '0px', null, '::after');
assertComputed(styledWide, '2px');
assertComputed(styledWide, '4px', null, '::after');

});

Expand Down

0 comments on commit ff88e17

Please sign in to comment.