Merge pull request #3310 from Polymer/fix-svg-scope

Fix svg scope
This commit is contained in:
Kevin Schaaf 2016-01-19 12:05:30 -08:00
commit 55b91b3db7
4 changed files with 948 additions and 947 deletions

View File

@ -283,14 +283,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
applyElementScopeSelector: function(element, selector, old, viaAttr) {
var c = viaAttr ? element.getAttribute(styleTransformer.SCOPE_NAME) :
element.className;
(element.getAttribute('class') || '');
var v = old ? c.replace(old, selector) :
(c ? c + ' ' : '') + this.XSCOPE_NAME + ' ' + selector;
if (c !== v) {
if (viaAttr) {
element.setAttribute(styleTransformer.SCOPE_NAME, v);
} else {
element.className = v;
element.setAttribute('class', v);
}
}
},

View File

@ -86,7 +86,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
.replace(scope, ''));
}
} else {
element.setAttribute(CLASS, c + (c ? ' ' : '') +
element.setAttribute(CLASS, (c ? c + ' ' : '') +
SCOPE_NAME + ' ' + scope);
}
}

View File

@ -231,6 +231,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('svg elements properly scoped', function() {
assert.include(styled.$.circle.getAttribute('class'), 'style-scope x-styled');
assert.notInclude(styled.$.circle.getAttribute('class'), 'null');
assertComputed(styled.$.circle, '1px', 'strokeWidth');
});