Eliminate runtime forking and long method lookup in `Element.hasAttribute`.

This commit is contained in:
Juriy Zaytsev 2009-11-13 12:27:10 -05:00
parent 829800834d
commit 9ef3f8d2ed
2 changed files with 10 additions and 4 deletions

View File

@ -1,3 +1,5 @@
* Eliminate runtime forking and long method lookup in `Element.hasAttribute`. (kangax)
* Remove redundant ternary. (kangax)
* Avoid repeating declaration statements where it makes sense, for slightly better runtime performance and minification. (kangax)

View File

@ -2036,10 +2036,14 @@ Element.extend = (function() {
return extend;
})();
Element.hasAttribute = function(element, attribute) {
if (element.hasAttribute) return element.hasAttribute(attribute);
return Element.Methods.Simulated.hasAttribute(element, attribute);
};
if (document.documentElement.hasAttribute) {
Element.hasAttribute = function(element, attribute) {
return element.hasAttribute(attribute);
};
}
else {
Element.hasAttribute = Element.Methods.Simulated.hasAttribute;
}
/**
* Element.addMethods(methods) -> undefined