<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><section><h1>仕様書</h1><refs xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:"><ul xmlns="http://www.w3.org/1999/xhtml"><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="11" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[11]</anchor-end> <cite xml:lang="en">DOM Standard</cite> (<time>2015-10-21 01:26:21 +09:00</time> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://dom.spec.whatwg.org/#dom-document-getelementsbytagname">https://dom.spec.whatwg.org/#dom-document-getelementsbytagname</anchor-external></li><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="12" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[12]</anchor-end> <cite xml:lang="en">DOM Standard</cite> (<time>2015-10-21 01:26:21 +09:00</time> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens">https://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens</anchor-external></li><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="9" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[9]</anchor-end> <cite xml:lang="en">DOM Standard</cite> (<time>2015-10-21 01:26:21 +09:00</time> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://dom.spec.whatwg.org/#dom-element-getelementsbytagname">https://dom.spec.whatwg.org/#dom-element-getelementsbytagname</anchor-external></li><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="10" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[10]</anchor-end> <cite xml:lang="en">DOM Standard</cite> (<time>2015-10-21 01:26:21 +09:00</time> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://dom.spec.whatwg.org/#dom-element-getelementsbytagnamens">https://dom.spec.whatwg.org/#dom-element-getelementsbytagnamens</anchor-external></li></ul></refs></section><section><h1>メモ</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="2" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[2]</anchor-end>
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">WinIE 6</anchor> (<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Windows XP</anchor> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">SP</anchor> 2) にて。</p><pre class="XML example">&lt;root xmlns:a=&quot;http://a.example/&quot;&gt;
  &lt;node&gt;
    <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="a:leaf/">a:leaf/</anchor-external>
  &lt;/node&gt;
&lt;/root&gt;</pre><p>この文書において 
<samp class="DOM"><code class="DOMm">getElementsByTagName</code> ('leaf')</samp>
とすると <code class="XMLe">leaf</code> 要素が得られる。
(この時点で <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">DOM</anchor> 的には異常だが。)</p><pre class="XML example">&lt;root&gt;
  &lt;node xmlns:a=&quot;http://a.example/&quot;&gt;
    <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="a:leaf/">a:leaf/</anchor-external>
  &lt;/node&gt;
&lt;/root&gt;</pre><p>等価な文書だが <weak xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">(<anchor>XML情報集合</anchor>的には少しだけ異なるが)</weak>、
<samp class="DOM"><code class="DOMm">getElementsByTagName</code> ('leaf')</samp>
しても <code class="XMLe">leaf</code>
要素は得られ<em>ない</em>。</p><pre class="XML example">&lt;root&gt;
  &lt;node&gt;
    <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="a:leaf xmlns:a=&quot;http://a.example/&quot;/">a:leaf xmlns:a=&quot;http://a.example/&quot;/</anchor-external>
  &lt;/node&gt;
&lt;/root&gt;</pre><p>これでも得られ<em>ない</em>。</p><p>ちなみに、<pre class="XML example">&lt;?xml-stylesheet href=&quot;style&quot; type=&quot;text/css&quot; media=&quot;all&quot;?&gt;
&lt;root&gt;
  &lt;node&gt;
    &lt;anotherLeaf/&gt;
    <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="a:leaf/">a:leaf/</anchor-external>
  &lt;/node&gt;
&lt;/root&gt;</pre></p><p>のような<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">名前空間整形式</anchor>でない文書を与えると、
<code class="XMLe">anotherLeaf</code>
の部分まで処理した後にエラー・メッセージが挿入されたものがレンダリングされる。</p><p>(<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">名無しさん</anchor> <weak xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">2005-04-17 04:18:08 +00:00</weak>)</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="3" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[3]</anchor-end>
<code class="DOMi" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Document</anchor></code> の<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">子孫</anchor>でない<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">節点</anchor>は<q>含まれている</q>ことになるのでしょうか?
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">DOM水準2</anchor>には<q><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">深さ優先探索</anchor></q>、
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">DOM水準3</anchor>には<q><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">文書順</anchor></q>とあり、
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">DOM水準3</anchor>の <code class="DOMm" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">compareDocumentPosition</anchor></code>
を考慮しても、含まれていることにはならないように思えます。
では、 <code class="DOMi" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Entity</anchor></code> の<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">子孫</anchor>は含まれているのでしょうか。
(<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">名無しさん</anchor>)</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="4" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[4]</anchor-end>
第一引数の名前は、 <code class="DOMi" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Document</anchor></code>
では <code class="DOMp" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">tagname</anchor></code> なのですが、
<code class="DOMi" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Element</anchor></code> では
<code class="DOMp" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">name</anchor></code> です。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="5" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[5]</anchor-end> <cite>IRC logs: freenode / #whatwg / 20121128</cite>
( (<time>2012-12-09 02:18:35 +09:00</time> 版))
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="http://krijnhoetmer.nl/irc-logs/whatwg/20121128#l-539">http://krijnhoetmer.nl/irc-logs/whatwg/20121128#l-539</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="6" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[6]</anchor-end> <cite xml:lang="en">Call out descendants for getElementsBy* in general · c3b4419 · whatwg/dom</cite>
( (<time>2014-11-23 18:31:36 +09:00</time> 版))
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/whatwg/dom/commit/c3b441965c013427b3936014205a5149c9971837">https://github.com/whatwg/dom/commit/c3b441965c013427b3936014205a5149c9971837</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="1" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[1]</anchor-end> <cite xml:lang="en">getElementsByTagName(): localName vs tagName</cite>
(<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Anne van Kesteren</anchor> 著, <time>2015-10-12 16:53:19 +09:00</time> 版)
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://lists.w3.org/Archives/Public/www-archive/2015Oct/0008.html">https://lists.w3.org/Archives/Public/www-archive/2015Oct/0008.html</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="7" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[7]</anchor-end> <cite xml:lang="en">492933 – getElementsByTagName should match on localName not tagName (for interop)</cite>
(<time>2015-10-19 14:22:53 +09:00</time> 版)
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://bugzilla.mozilla.org/show_bug.cgi?id=492933">https://bugzilla.mozilla.org/show_bug.cgi?id=492933</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="8" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[8]</anchor-end> <cite xml:lang="en">Fix #90 better: only branch on type to allow more caching · whatwg/dom@10c9c14</cite> (<time>2015-10-23 11:56:21 +09:00</time> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/whatwg/dom/commit/10c9c14a00897664af4fbb426939a046f8e79f4f">https://github.com/whatwg/dom/commit/10c9c14a00897664af4fbb426939a046f8e79f4f</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="13" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[13]</anchor-end> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Chrome</anchor> で (<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTML文書</anchor>と<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">XML文書</anchor>で種別が異なる) 他の<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">文書</anchor>に <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">adopt</anchor>
する前後で取得した <code class="DOMm" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">getElementsByTagName</anchor></code> の
<code class="DOMi" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTMLCollection</anchor></code> は、異なります。
元の<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">文書</anchor>に再び <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">adopt</anchor> すると、前と同じ <code class="DOMi" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTMLCollection</anchor></code>
がまた得られます。<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">メソッド</anchor>がどのオブジェクトを返すかに関わらず、
既に得られた <code class="DOMi" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTMLCollection</anchor></code> は正常に動作します (<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">文書</anchor>が変わっても
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">live</anchor> のままです)。
<time>2015-10-23T03:06:46.400Z</time></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="14" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[14]</anchor-end> <cite xml:lang="en">Make it clear getElementsByTagName operates on descendants · whatwg/dom@e012ffe</cite>
(<time>2016-01-02 11:23:04 +09:00</time> 版)
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/whatwg/dom/commit/e012ffee0c806331c20f534371ae4e0c0fff1e28">https://github.com/whatwg/dom/commit/e012ffee0c806331c20f534371ae4e0c0fff1e28</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="15" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[15]</anchor-end> <cite xml:lang="en">Fix #143: make getElementsByTagName match on qualified name · whatwg/dom@7fd852a</cite>
(<time>2016-01-30 20:44:49 +09:00</time> 版)
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/whatwg/dom/commit/7fd852ae910e6798373f32f655670f14c4fe5a20">https://github.com/whatwg/dom/commit/7fd852ae910e6798373f32f655670f14c4fe5a20</anchor-external></p></section></body></html>