Forum Moderators: open
if(node.hasAttribute(attr)) ...
Does anyone know a clean way (ie. not using browser detection) to have IE(Mac) skip this line?
W3C DOM Compatibility and test cases [quirksmode.org]
[pxl8.com ]
..but then again, the 3 tests they do [==null,=="",==undefined]
since all [null,"",undefined] evaluate to false,
can be rolled into one - similar to below, but opposite.
if(!node.getAttribute(attr))
</edit>
Hmm. No browser detection. Do you mean directly? As in querying navigator string etc?
Or generally. A test for IE mac (once IE is established) could be a test for the constructor:
if(!ActiveXObject) [hmmm. what happens if it's disabled? Anyway, something similar]
Otherwise:
if(node.hasAttribute && node.hasAttribute(attr)) but if IE mac was failing silently before, then it's likely that it will pass the new first condition too.
(Another IE mac "phantom method").
Would it be possible to use getAttribute instead?
In all cases (since XHTML element attributes must have values)
if(node.getAttribute(attr)) will save the same purpose in your code.
...perhaps
if(node.hasAttribute) {
if(node.hasAttribute(attr)) return node.getAttribute(attr);
} which is pretty much what you said ;)