Re: Ambiguity in removeAttributeNode

* Travis Leithead wrote:
>We happened to notice an interesting behavior difference in
>removeAttributeNode recently, and an appeal to the standard didn't seem
>to help...

>            var pElem = document.getElementById('foo');
>            var newAttr = document.createAttribute('align');
>            newAttr.value = "right";
>            try {
>                  var oldAttr = pElem.removeAttributeNode(newAttr);

>      <p id="foo" align="left">Sample text</p>

>IE fails in this example and triggers the try/catch. FF works, Opera
>also fails. It seems that some browser implementers deciphered the DOM
>Core spec::removeAttributeNode to mean that "object" comparison is used
>as the delete criteria, but others seem to only base it on the "name" of
>the Attr. 

Well, removeAttributeNode removes the specified attribute node from the
element the method is called on, and raises a NOT_FOUND_ERR exception
"if oldAttr is not an attribute of the element"; that seems very clear
to me, in your example newAttr is not an attribute of pElem since new-
Attr.ownerElement != pElem.

>Is there hope in coming to harmony across implementations on this point?

This just seems to be a bug in Firefox, if somebody files it, it should
be fixed sooner or later.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Saturday, 28 July 2007 06:07:25 UTC