Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29143

Re: "getElementsByTagName" and namespaces

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: "getElementsByTagName" and namespaces
Date 2016-01-04 22:45 +0100
Organization PointedEars Software (PES)
Message-ID <14239577.c6YeJJazIk@PointedEars.de> (permalink)
References <namespaces-20160104175017@ram.dialup.fu-berlin.de>

Show all headers | View raw


Stefan Ram wrote:

>   The DOM4 specification of the W3C says:
> 
>       »The getElementsByTagName(localName) method must return
>       the list of elements with local name localName for the
>       context object. Note: Thus, in an HTML document,
>       document.getElementsByTagName("FOO") will match FOO
>       elements that are not in the HTML namespace, and foo
>       elements that are in the HTML namespace, but not FOO
>       elements that are in the HTML namespace.«
> 
>   So, why will the uppercase argument »FOO« match
>   lowercase names from the HTML namespace but not
>   uppercase names from it?

Again you should have cited your reference and given the URI of the quoted 
specification, <http://www.w3.org/TR/2015/REC-dom-20151119/#dom-document-getelementsbytagname>.

Why getElementsByTagName() is supposed to work this way is explained in the 
part that the link with text “list of elements with local name /localName/” 
refers to:

,-<http://www.w3.org/TR/2015/REC-dom-20151119/#concept-getelementsbytagname>
| 
| The list of elements with local name /localName/ for a node /root/ is the 
| `HTMLCollection` returned by the following algorithm:
| 
| 1. If /localName/ is "*" (U+002A), return a `HTMLCollection` rooted at 
|    /root/, whose filter matches only elements.
| 
| 2. Otherwise, if /root/'s node document is an HTML document, return a 
|    `HTMLCollection` rooted at /root/, whose filter matches the following 
|    descendant elements:
| 
|    * Whose namespace is the HTML namespace and whose local name is 
|      /localName/ converted to ASCII lowercase.
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

That excludes “FOO” elements *in the HTML namespace* with 
getElementsByTagName("FOO"), and leaves only “foo” elements *in that 
namespace*.

|    * Whose namespace is not the HTML namespace and whose local name is 
|      /localName/.
       ^^^^^^^^^^^

That includes “FOO” elements *not in the HTML namespace* with 
getElementsByTagName("FOO").
 
| 3. Otherwise, return a `HTMLCollection` rooted at /root/, whose filter 
|    matches descendant elements whose local name is /localName/.

> [troll bait]

Nice try.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread


Thread

Re: "getElementsByTagName" and namespaces Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-04 22:45 +0100

csiph-web