Skip to content

Commit

Permalink
Fixes #2263: ensure custom-style can parse variable definitions in su…
Browse files Browse the repository at this point in the history
…pported selectors (e.g. /deep/) without exception due to unknown css.
  • Loading branch information
Steven Orvell committed Aug 20, 2015
1 parent 0f8483d commit 894492b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/lib/custom-style.html
Expand Up @@ -135,11 +135,13 @@
if (this.include) {
e.textContent += styleUtil.cssFromModules(this.include);
}
var rules = styleUtil.rulesForStyle(e);
styleUtil.forEachStyleRule(rules, function(rule) {
styleTransformer.documentRule(rule);
});
this._computeStyleProperties();
var props = this._styleProperties;
var self = this;
e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e),
function(rule) {
e.textContent = styleUtil.toCssText(rules, function(rule) {
var css = rule.cssText = rule.parsedCssText;
if (rule.propertyInfo && rule.propertyInfo.cssText) {
// remove property assignments
Expand All @@ -154,7 +156,6 @@
// replace with reified properties, scenario is same as mixin
rule.cssText = propertyUtils.valueForProperties(css, props);
}
styleTransformer.documentRule(rule);
}
);
}
Expand Down
15 changes: 14 additions & 1 deletion test/unit/custom-style.html
Expand Up @@ -73,6 +73,10 @@
--primary: 10px;
}

body /deep/ * {
--deeep: 6px solid orange;
}


</style>
<style is="custom-style">
Expand Down Expand Up @@ -156,18 +160,23 @@
div {
@apply(--bag);
}

#deep {
border: var(--deeep);
}
</style>
<template>
<div id="me">x-foo</div>
<x-bar id="bar1"></x-bar>
<x-bar id="bar2"></x-bar>
<x-bar id="bar3"></x-bar>
<div id="deep">deep</div>
</template>
</dom-module>

<script>

suite('x-style', function() {
suite('custom-style', function() {

suiteSetup(function() {

Expand Down Expand Up @@ -261,6 +270,10 @@
assert.include(url, 'sub/google.png');
});

test('property in /deep/ rule applied via document scope inheritance', function() {
assertComputed(xFoo.$.deep, '6px');
});

});


Expand Down

0 comments on commit 894492b

Please sign in to comment.