Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
make :host(.bar:not(.zot)) > #wahtever { work
Browse files Browse the repository at this point in the history
supports 1 level of nesting inside the :host(…)
  • Loading branch information
sorvell committed Nov 21, 2013
1 parent 0755e8a commit 4f727e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ShadowCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ var hostRuleRe = /@host[^{]*{(([^}]*?{[^{]*?}[\s\S]*?)+)}/gim,
// note: :host pre-processed to -shadowcsshost.
polyfillHost = '-shadowcsshost',
cssColonHostRe = new RegExp('(' + polyfillHost +
')(?:\\(([^)]*)\\))?([^,{]*)', 'gim'),
')(?:\\((' +
'(?:\\([^)(]*\\)|[^)(]*)+?' +
')\\))?([^,{]*)', 'gim'),
selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$',
hostRe = /@host/gim,
colonHostRe = /\:host/gim,
Expand Down
14 changes: 14 additions & 0 deletions test/html/styling/colon-host.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
background: black;
color: white;
}

:host(.opened:not(.animating)) div {
background: blue;
}
</style>
<div>background</div>
</template>
Expand Down Expand Up @@ -162,6 +166,11 @@ <h4>Expected: 20px padding</h4>
<h4>Expected: blue background</h4>
<a href="#" is="x-anchor">Test Link</a>
</div>
<h4>Expected: blue background</h4>
<div class="opened">
<x-foo class="foo3"></x-foo>
</div>
</div>

<script>
document.addEventListener('WebComponentsReady', function() {
Expand All @@ -173,6 +182,11 @@ <h4>Expected: blue background</h4>
chai.assert.equal(getComputedStyle(foo2).backgroundColor, 'rgb(0, 0, 0)',
':host styles are conditionally applied (backgroundColor)');

var foo3 = document.querySelector('x-foo.foo3');
var foo3div = foo3.querySelector('div');
chai.assert.equal(getComputedStyle(foo3div).backgroundColor, 'rgb(0, 0, 255)',
':host(:not()) styles are applied (backgroundColor)');

var scope = document.querySelector('x-scope');
chai.assert.equal(getComputedStyle(scope).backgroundColor, 'rgb(255, 0, 0)',
':host styles matching :scope are applied (backgroundColor)');
Expand Down

0 comments on commit 4f727e1

Please sign in to comment.