Skip to content

Commit f05b74f

Browse files
committed
Merge pull request #21 from sjmiles/master
"DOMTokenList.enable" was renamed to "toggle" at platform, update polyfill
2 parents c073e71 + 952630e commit f05b74f

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

src/g-component.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
};
1919

2020
// polyfill for DOMTokenList features: list of classes in add/remove;
21-
// enable method.
21+
// toggle method.
2222
(function() {
2323
'use strict';
2424
var add = DOMTokenList.prototype.add;
@@ -33,7 +33,10 @@
3333
remove.call(this, arguments[i]);
3434
}
3535
};
36-
DOMTokenList.prototype.enable = function(name, value) {
36+
DOMTokenList.prototype.toggle = function(name, value) {
37+
if (value == undefined) {
38+
value = !this.contains(name);
39+
}
3740
value ? this.add(name) : this.remove(name);
3841
};
3942
})();

src/g-icon-button.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
this.$.icon.src = this.src;
2020
},
2121
activeChanged: function() {
22-
this.classList.enable('selected', this.active);
22+
this.classList.toggle('selected', this.active);
2323
}
2424
}
2525
});

src/g-ratings.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
prototype: {
2727
valueAttributeChanged: function() {
2828
for (var i=0, s; s=this.stars[i]; i++) {
29-
s.classList.enable('full', i < Number(this.value));
29+
s.classList.toggle('full', i < Number(this.value));
3030
}
3131
},
3232
clickHandler: function(e) {

src/g-tabs.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
this.component({
1818
prototype: {
1919
verticalChanged: function() {
20-
this.classList.enable('vertical', this.vertical);
20+
this.classList.toggle('vertical', this.vertical);
2121
}
2222
}
2323
});

src/g-togglebutton.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
this.component({
2020
prototype: {
2121
valueChanged: function() {
22-
this.$.toggle.classList.enable('on', this.value);
22+
this.$.toggle.classList.toggle('on', this.value);
2323
},
2424
toggle: function() {
2525
this.value = !this.value;

0 commit comments

Comments
 (0)