Path: csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: "getElementsByTagName" and namespaces Date: Mon, 04 Jan 2016 22:45:20 +0100 Organization: PointedEars Software (PES) Lines: 62 Message-ID: <14239577.c6YeJJazIk@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1451943921 31402 eJwFwYEBwCAIA7CX7IRWznGD/n/CktwEPwWTkU533eoeXhCjrVA6UGYtdOsJ+/ScjRdeMfoBIJMRGQ== (4 Jan 2016 21:45:21 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Mon, 4 Jan 2016 21:45:21 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwNwokRACEIBLCWRGFXykGe/ku4m8QOBEmFQW1+PbccNpuB7tHDdXIMof2YIWOLSXpW0fcT86hVyXtf1uYHbGUWQQ== Cancel-Lock: sha1:GxxTYtSeGCtQj1CjkoFu+haP5oQ= X-NNTP-Posting-Host: eJwFwQEBwCAQAsBKog+4ODqlfwTvOAT9LlHFMMa+E/qumwYUz43WD2rc5Zg89IacXnFWPQZwEIA= Xref: csiph.com comp.lang.javascript:29143 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, . 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: ,- | | 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: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.