add DOMTokenList polyfill (ad-hoc: directly in g-component)

This commit is contained in:
Scott Miles
2012-10-12 13:37:29 -07:00
parent 4ac8d9a24f
commit c8cf70019d

View File

@@ -11,6 +11,27 @@ license that can be found in the LICENSE file.
});
</script>
<script>
// polyfill for DOMTokenList features: list of classes in add/remove;
// enable method.
(function() {
'use strict';
var add = DOMTokenList.prototype.add;
var remove = DOMTokenList.prototype.remove;
DOMTokenList.prototype.add = function() {
for (var i = 0; i < arguments.length; i++) {
add.call(this, arguments[i]);
}
};
DOMTokenList.prototype.remove = function() {
for (var i = 0; i < arguments.length; i++) {
remove.call(this, arguments[i]);
}
};
DOMTokenList.prototype.enable = function(name, value) {
value ? this.add(name) : this.remove(name);
};
})();
(function(){
var bindAttrs = function(inAttrs) {
inAttrs.forEach(function(a) {