From d1af5a61dd00a30b8898555d86d05c5e6765bf41 Mon Sep 17 00:00:00 2001 From: Scott Miles Date: Tue, 23 Oct 2012 14:58:52 -0700 Subject: [PATCH] DOMTokenList.enable was renamed to toggle at platform --- src/g-component.html | 7 +++++-- src/g-icon-button.html | 2 +- src/g-ratings.html | 2 +- src/g-tabs.html | 2 +- src/g-togglebutton.html | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/g-component.html b/src/g-component.html index 2d1a1672..0b01efad 100644 --- a/src/g-component.html +++ b/src/g-component.html @@ -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); }; })(); diff --git a/src/g-icon-button.html b/src/g-icon-button.html index 9d952da4..345ae8da 100644 --- a/src/g-icon-button.html +++ b/src/g-icon-button.html @@ -19,7 +19,7 @@ this.$.icon.src = this.src; }, activeChanged: function() { - this.classList.enable('selected', this.active); + this.classList.toggle('selected', this.active); } } }); diff --git a/src/g-ratings.html b/src/g-ratings.html index d2978bcb..04777013 100644 --- a/src/g-ratings.html +++ b/src/g-ratings.html @@ -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) { diff --git a/src/g-tabs.html b/src/g-tabs.html index 6f7a9ca9..aeb79955 100644 --- a/src/g-tabs.html +++ b/src/g-tabs.html @@ -17,7 +17,7 @@ this.component({ prototype: { verticalChanged: function() { - this.classList.enable('vertical', this.vertical); + this.classList.toggle('vertical', this.vertical); } } }); diff --git a/src/g-togglebutton.html b/src/g-togglebutton.html index 30b5ef0a..fe5dfbc9 100644 --- a/src/g-togglebutton.html +++ b/src/g-togglebutton.html @@ -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;