Fix for scoping when class is not specified on element (null was prepended instead of empty string)

This commit is contained in:
Nazar Mokrynskyi 2015-12-20 06:59:34 +01:00
parent 4a9ef8e96d
commit 24e9fc79a3
3 changed files with 18 additions and 1 deletions

View File

@ -215,7 +215,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_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 : '');
}

View File

@ -442,3 +442,12 @@
is: 'x-overriding'
});
</script>
<script>
Polymer({
is: 'x-scope-no-class',
ready: function() {
this.scopeSubtree(this, true);
}
});
</script>

View File

@ -51,6 +51,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</div>
<x-overriding></x-overriding>
<x-scope-no-class>
<div></div>
</x-scope-no-class>
<script>
suite('scoped-styling', function() {
@ -273,6 +277,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
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() {