compat shim fixes

This commit is contained in:
Andrew Dolgov 2021-02-18 22:14:40 +03:00
parent f77c17c6f0
commit e61e7c8356
1 changed files with 12 additions and 7 deletions

View File

@ -4,22 +4,24 @@
/* eslint-disable no-new */ /* eslint-disable no-new */
Element.prototype.hasClassName = function(className) { Element.prototype.hasClassName = function(className) {
dojo.hasClass(this, className); return dojo.hasClass(this, className);
}; };
Element.prototype.addClassName = function(className) { Element.prototype.addClassName = function(className) {
dojo.addClass(this, className); return dojo.addClass(this, className);
}; };
Element.prototype.removeClassName = function(className) { Element.prototype.removeClassName = function(className) {
dojo.removeClass(this, className); return dojo.removeClass(this, className);
}; };
Element.prototype.toggleClassName = function(className) { Element.prototype.toggleClassName = function(className) {
console.log(this, className);
if (this.hasClassName(className)) if (this.hasClassName(className))
this.removeClassName(className); return this.removeClassName(className);
else else
this.addClassName(className); return this.addClassName(className);
}; };
@ -77,8 +79,11 @@ Element.toggle = function(elem) {
return elem.toggle(); return elem.toggle();
} }
Element.hasClassName = function (id, className) { Element.hasClassName = function (elem, className) {
return document.getElementById(id).hasClassName(className); if (typeof elem == "string")
elem = document.getElementById(elem);
return elem.hasClassName(className);
} }
/* xhr shorthand helpers */ /* xhr shorthand helpers */