Skip to content

Commit

Permalink
Merge pull request #21 from sjmiles/master
Browse files Browse the repository at this point in the history
"DOMTokenList.enable" was renamed to "toggle" at platform, update polyfill
  • Loading branch information
frankiefu committed Oct 23, 2012
2 parents c073e71 + 952630e commit f05b74f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/g-component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
};

// polyfill for DOMTokenList features: list of classes in add/remove;
// enable method.
// toggle method.
(function() {
'use strict';
var add = DOMTokenList.prototype.add;
Expand All @@ -33,7 +33,10 @@
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);
};
})();
Expand Down
2 changes: 1 addition & 1 deletion src/g-icon-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
this.$.icon.src = this.src;
},
activeChanged: function() {
this.classList.enable('selected', this.active);
this.classList.toggle('selected', this.active);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/g-ratings.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/g-tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
this.component({
prototype: {
verticalChanged: function() {
this.classList.enable('vertical', this.vertical);
this.classList.toggle('vertical', this.vertical);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/g-togglebutton.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f05b74f

Please sign in to comment.