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


Groups > comp.lang.javascript > #29143 > unrolled thread

Re: "getElementsByTagName" and namespaces

Started byThomas 'PointedEars' Lahn <PointedEars@web.de>
First post2016-01-04 22:45 +0100
Last post2016-01-04 22:45 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.javascript

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#29143 — Re: "getElementsByTagName" and namespaces

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-01-04 22:45 +0100
SubjectRe: "getElementsByTagName" and namespaces
Message-ID<14239577.c6YeJJazIk@PointedEars.de>
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.

[toc] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web