getElementsByTagName() bug?

DOMCore defines getElementsByTagName() like this:

> The |getElementsByTagName(localName)| method must run these steps:
>
> 1.
>
>     If localName is "|*|" (U+002A), return a |NodeList
>     <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#nodelist>|
>     rooted at the context object
>     <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#context-object>,
>     whose filter matches only |Element
>     <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#element>| nodes.
>
>
> 2.
>
>     Otherwise, if the context object
>     <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#context-object>
>     is an HTML document
>     <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#html-document>,
>     return a |NodeList
>     <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#nodelist>|
>     rooted at the context object
>     <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#context-object>,
>     whose filter matches only the following nodes:
>
>       * |Element
>         <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#element>|
>         nodes in the HTML namespace
>         <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#html-namespace>
>         whose local name
>         <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name>
>         is localName converted to ASCII lowercase
>         <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#converted-to-ascii-lowercase>.
>
>       * |Element
>         <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#element>|
>         nodes, /not/ in the HTML namespace
>         <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#html-namespace>,
>         whose local name
>         <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name>
>         is localName.
> 3.
>
>     Otherwise, return a |NodeList
>     <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#nodelist>|
>     rooted at the context object
>     <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#context-object>,
>     whose filter matches only elements
>     <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element>
>     whose local name
>     <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name>
>     is localName.
>
That is, it filters elements based on their local name without any 
namespace prefix. But this is inconsistent with the Element.tagName 
attribute, which returns the qualified name of the element, including 
the namespace prefix.

Also, it is not consistent with Firefox's behavior (I didn't test other 
browsers) or with lines 28-32 of ms2ger's test case: 
https://dvcs.w3.org/hg/webapps/file/2de86e9886ef/DOMCore/tests/submissions/Ms2ger/Document-getElementsByTagName.html

(On the other hand, line 35 and 36 of the same test case don't seem to 
be consistent with the spec as it stands or with Firefox, so the test 
case might be in error here.)

     David

Received on Wednesday, 6 July 2011 21:37:58 UTC