Make classList a getter so it can be lazy; dom mutation api's only cause distribution on parent.

This commit is contained in:
Steven Orvell
2015-05-11 18:01:24 -07:00
parent 8d7570516f
commit 1deb578c3b

View File

@@ -29,7 +29,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
if (this.patch) {
this.patch();
}
this.classList = new DomApi.ClassList(this);
};
DomApi.prototype = {
@@ -369,8 +368,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
},
// TODO(sorvell): make Polymer utils use these...
setAttribute: function(name, value) {
this.node.setAttribute(name, value);
this._distributeParent();
@@ -383,12 +380,22 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_distributeParent: function() {
if (this.parentNode && this.parentNode.shadyRoot) {
this.parentNode.distributeContent();
this._lazyDistribute(this.parentNode);
}
}
};
Object.defineProperty(DomApi.prototype, 'classList', {
get: function() {
if (!this._classList) {
this._classList = new DomApi.ClassList(this);
}
return this._classList;
},
configurable: true
});
DomApi.ClassList = function(host) {
this.domApi = host;
this.node = host.node;