mirror of
https://github.com/Polymer/polymer.git
synced 2026-08-19 01:14:44 -05:00
Ensure initial static classes are preserved when a class$ binding is present.
This ensures ShadyCSS scoping classes are not removed when a class binding's initial literal value is set.
This commit is contained in:
@@ -2551,6 +2551,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// Initialize attribute bindings with any literal parts
|
||||
let literal = literalFromParts(parts);
|
||||
if (literal && kind == 'attribute') {
|
||||
// Ensure a ShadyCSS template scoped style is not removed
|
||||
// when a class$ binding's initial literal value is set.
|
||||
if (name == 'class' && node.hasAttribute('class')) {
|
||||
literal += ' ' + node.getAttribute(name);
|
||||
}
|
||||
node.setAttribute(name, literal);
|
||||
}
|
||||
// Clear attribute before removing, since IE won't allow removing
|
||||
|
||||
@@ -160,6 +160,19 @@ HTMLImports.whenReady(function() {
|
||||
</script>
|
||||
</dom-module>
|
||||
|
||||
<dom-module id="x-class-literal">
|
||||
<template>
|
||||
<div id="scope" class$="a [[b]] c" class="d e">Trivial</div>
|
||||
</template>
|
||||
<script>
|
||||
HTMLImports.whenReady(function() {
|
||||
Polymer({
|
||||
is: 'x-class-literal'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
||||
|
||||
|
||||
|
||||
<dom-module id="x-styled">
|
||||
@@ -1041,6 +1054,17 @@ HTMLImports.whenReady(function() {
|
||||
assertComputed(e, '2px');
|
||||
});
|
||||
|
||||
test('initial literal values in class are preserved when a class$ binding is present', function() {
|
||||
var e = document.createElement('x-class-literal');
|
||||
document.body.appendChild(e);
|
||||
var el = e.$.scope;
|
||||
assert.equal(el.classList.length, 4);
|
||||
assert.isTrue(el.classList.contains('a'));
|
||||
assert.isTrue(el.classList.contains('c'));
|
||||
assert.isTrue(el.classList.contains('d'));
|
||||
assert.isTrue(el.classList.contains('e'));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('double including style sheets', function() {
|
||||
|
||||
Reference in New Issue
Block a user