diff --git a/CHANGELOG b/CHANGELOG index f762443..a194049 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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) diff --git a/src/dom/dom.js b/src/dom/dom.js index a3db44c..7876327 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -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