hasAttributemethod of dom elements. Which isn't that bad since its fairly trivial to replace
getAttribute. The scary thing is that this issue has been present since November 2007.
Apparently (looking through the history) there was an attempt to fix back in January of 2008, by changing
getAttribute('missing', 2) == "". (I'm not sure where the 2 came from. All the docs i've read seem to state that
getAttributeonly takes 1 parameter) This almost would have worked, except for one important fact. In the mediawiki api, if you try to find info on a non-exisistant page, it will give you:
missing="" /> Thus the normal value for the attribute if present is "", and if its not present, according to the w3c
getArributeshould return the empty string. Thus testing for the empty string doesn't work, as it returns the empty string in both cases. However in practice this doesn't seem entirely true, as in both Firefox and IE, when
getAttributeis used on a missing attribute, the browser returns
""(The previous code of
getAttribute('missing', 2) == ""would still of worked since
"" == null)
To fix the problem, the code in question now first tries to use the
hasAttribute()method (for the good little browsers that support it), and if that throws an exception, it will see if
getAttribute(attributeName) !== null. (assuming that anybody who doesn't support
hasAttributealso returns null when getting a non-existant attribute.