Merge pull request #21 from sjmiles/master

"DOMTokenList.enable" was renamed to "toggle" at platform, update polyfill
This commit is contained in:
Frankie Fu
2012-10-23 15:13:52 -07:00
5 changed files with 9 additions and 6 deletions

View File

@@ -18,7 +18,7 @@ license that can be found in the LICENSE file.
};
// polyfill for DOMTokenList features: list of classes in add/remove;
// enable method.
// toggle method.
(function() {
'use strict';
var add = DOMTokenList.prototype.add;
@@ -33,7 +33,10 @@ license that can be found in the LICENSE file.
remove.call(this, arguments[i]);
}
};
DOMTokenList.prototype.enable = function(name, value) {
DOMTokenList.prototype.toggle = function(name, value) {
if (value == undefined) {
value = !this.contains(name);
}
value ? this.add(name) : this.remove(name);
};
})();

View File

@@ -19,7 +19,7 @@
this.$.icon.src = this.src;
},
activeChanged: function() {
this.classList.enable('selected', this.active);
this.classList.toggle('selected', this.active);
}
}
});

View File

@@ -26,7 +26,7 @@
prototype: {
valueAttributeChanged: function() {
for (var i=0, s; s=this.stars[i]; i++) {
s.classList.enable('full', i < Number(this.value));
s.classList.toggle('full', i < Number(this.value));
}
},
clickHandler: function(e) {

View File

@@ -17,7 +17,7 @@
this.component({
prototype: {
verticalChanged: function() {
this.classList.enable('vertical', this.vertical);
this.classList.toggle('vertical', this.vertical);
}
}
});

View File

@@ -19,7 +19,7 @@
this.component({
prototype: {
valueChanged: function() {
this.$.toggle.classList.enable('on', this.value);
this.$.toggle.classList.toggle('on', this.value);
},
toggle: function() {
this.value = !this.value;