Skip to content

Commit

Permalink
Fix for scoping when class is not specified on element (null was prep…
Browse files Browse the repository at this point in the history
…ended instead of empty string)
  • Loading branch information
nazar-pc committed Feb 4, 2016
1 parent 4a9ef8e commit 24e9fc7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/standard/x-styling.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@

_scopeElementClass: function(element, selector) {
if (!nativeShadow && !this._scopeCssViaAttr) {
selector += (selector ? ' ' : '') + SCOPE_NAME + ' ' + this.is +
selector = (selector ? selector + ' ' : '') + SCOPE_NAME + ' ' + this.is +
(element._scopeSelector ? ' ' + XSCOPE_NAME + ' ' +
element._scopeSelector : '');
}
Expand Down
9 changes: 9 additions & 0 deletions test/unit/styling-scoped-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,12 @@
is: 'x-overriding'
});
</script>

<script>
Polymer({
is: 'x-scope-no-class',
ready: function() {
this.scopeSubtree(this, true);
}
});
</script>
8 changes: 8 additions & 0 deletions test/unit/styling-scoped.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
</div>
<x-overriding></x-overriding>

<x-scope-no-class>
<div></div>
</x-scope-no-class>

<script>
suite('scoped-styling', function() {

Expand Down Expand Up @@ -273,6 +277,10 @@
test('specificity of ::content > :not(template) selector', function() {
assertComputed(document.querySelector('[is=x-specificity-nested]'), '10px');
});

test('x-scope with no class attribute', function () {
assert.equal(document.querySelector('x-scope-no-class > div').className, 'style-scope x-scope-no-class');
})
});

test('svg classes are dynamically scoped correctly', function() {
Expand Down

0 comments on commit 24e9fc7

Please sign in to comment.