Skip to content

Commit

Permalink
Ensure element scope selectors are updated correctly when updateStyle…
Browse files Browse the repository at this point in the history
…s is called when element is not in dom.
  • Loading branch information
Steven Orvell committed Jun 23, 2016
1 parent ae4a07e commit 6d90480
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/standard/x-styling.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
_beforeAttached: function() {
// note: do this once automatically,
// then requires calling `updateStyles`
if (!this._scopeSelector && this._needsStyleProperties()) {
if ((!this._scopeSelector || this.__stylePropertiesInvalid) &&
this._needsStyleProperties()) {
this.__stylePropertiesInvalid = false;
this._updateStyleProperties();
}
},
Expand Down Expand Up @@ -274,7 +276,7 @@
// if called when an element is not attached, invalidate
// styling by unsetting scopeSelector.
} else {
this._scopeSelector = null;
this.__stylePropertiesInvalid = true;
}
if (this._styleCache) {
this._styleCache.clear();
Expand Down
6 changes: 6 additions & 0 deletions test/unit/styling-cross-scope-var.html
Original file line number Diff line number Diff line change
Expand Up @@ -979,11 +979,17 @@
assertComputed(x.$.child, '6px');
x.active = false;
assertComputed(x.$.child, '0px');
var scopeSelector = x.$.child._scopeSelector;
document.body.removeChild(x);
CustomElements.takeRecords();
x.active = true;
document.body.appendChild(x);
CustomElements.takeRecords();
if (styled.shadyRoot && !Polymer.Settings.useNativeCSSProperties) {
assert.notEqual(scopeSelector, x.$.child._scopeSelector);
assert.isTrue(x.$.child.classList.contains(x.$.child._scopeSelector));
assert.isFalse(x.$.child.classList.contains(scopeSelector));
}
assertComputed(x.$.child, '6px');
});

Expand Down

0 comments on commit 6d90480

Please sign in to comment.