[2] [CODE(DOMi)@en[[[DocumentFragment]]]] の「[[親]]」に相当する[[節点]]のことを[DFN[[RUBYB[[[ホスト]]]@en[host]]]]といいます。

* 仕様書

[REFS[
- [1] [CITE@en-US[DOM Standard]] ([TIME[2013-12-10 15:02:55 +09:00]] 版) <http://dom.spec.whatwg.org/#concept-documentfragment-host>
- [19] [CITE@en[DOM Standard]] ([TIME[2016-04-26 13:45:33 +09:00]] 版) <https://dom.spec.whatwg.org/#dom-shadowroot-host>
- [21] [CITE@en[DOM Standard]] ([TIME[2016-04-26 13:45:33 +09:00]] 版) <https://dom.spec.whatwg.org/#element-shadow-host>
]REFS]

* 定義

[FIG[
>
[3] [CODE(DOMi)@en[[[DocumentFragment]]]] [[節点]]は、関連付けられた[[要素]]「[DFN[[RUBYB[ホスト]@en[host]]]]」
を持つことができます。

[FIGCAPTION[
[SRC[>>1]]
]FIGCAPTION]
]FIG]

* 用法

[5] [CODE(HTMLe)@en[[[template]]]] [[要素]]は、関連付けられた [CODE(DOMi)@en[[[DocumentFragment]]]]
を持ち、これを[[雛形内容]]といいます。従って[[ホスト]]と[[雛形内容]]は逆方向の関係になります。

;; [7] この場合[[ホスト]]と [CODE(DOMi)@en[[[DocumentFragment]]]] で[[節点文書]]が異なります。

[HISTORY[
[16] ただしなぜかこれが[[ホスト]]関係であることは 2016年3月までは
[[DOM Standard]] にも [[HTML Standard]]
にも明記されていませんでした。

;; [10] [CODE(DOMi)@en[[[HTMLTemplateElement]]]] の [CODE(DOMa)@en[[[content]]]] で[[ホスト]]から 
[CODE(DOMi)@en[[[DocumentFragment]]]] への[[強い参照]]がありますが、逆方向には参照がありません。
]HISTORY]

[6] [[影根]] ([CODE(DOMi)@en[[[ShadowRoot]]]]) に対する[[影ホスト]]も[[ホスト]]です。

;; [8] この場合[[影ホスト]]と[[影根]]で[[節点文書]]は同じです。

;; [9] [CODE(DOMi)@en[[[Element]]]] の [CODE(DOMa)@en[[[shadowRoot]]]] と
[CODE(DOMi)@en[[[ShadowRoot]]]] の [CODE(DOMa)@en[host][host (DOM)]] で双方向に[[強い参照]]があります。

[22] [[要素]]の[F[影根]]が [[null]] でないとき、
その[[要素]]は[DFN[[RUBYB[[[影ホスト]]]@en[shadow host]]]]です [SRC[>>21]]。

* [CODE(DOMa)@en[host][host (DOM)]] 属性

[18] [CODE(DOMi)@en[ShadowRoot]] [[インターフェイス]]の
[CODE(DOMa)@en[host][host (DOM)]] [[IDL属性]]の[[取得器]]は、
[[文脈オブジェクト]]の[F[ホスト][ホスト (DOM)]]を返さなければ[MUST[なりません]] [SRC[>>19]]。

[20] [[影根]]は、常に[[要素]]の[F[ホスト][ホスト (DOM)]]を持ちます。

[14] [CODE(DOMi)@en[DocumentFragment]] [[インターフェイス]]ではなく
[CODE(DOMi)@en[ShadowRoot]] [[インターフェイス]]に
[CODE(DOMa)@en[host][host (DOM)]] [[IDL属性]]が定義されています。

[15] ですから、[[雛形内容]]から [CODE(HTMLe)@en[template]]
[[要素]]をたどることはできません。

* 歴史

[4] [[ホスト]]の概念は [CODE(HTMLe)@en[[[template]]]] [[要素]]と[[影DOM]]のために2013年に [[DOM]] に追加されました。


[11] [CITE@en[Shadow: add shadow root · whatwg/dom@b2ee400]]
([TIME[2016-03-16 14:24:10 +09:00]] 版)
<https://github.com/whatwg/dom/commit/b2ee400a6542dc76d41bed5d2edb8c85ba241bfc>

[12] [CITE@en[Editorial: be clearer on host, define light tree · whatwg/dom@ce7df0b]]
([TIME[2016-03-20 18:55:44 +09:00]] 版)
<https://github.com/whatwg/dom/commit/ce7df0bfe425b4502bb40e66806dd76f14fcf68b>

[13] [CITE@en[Set <template>'s DocumentFragment's host · whatwg/html@baa8e34]]
([TIME[2016-03-20 18:57:13 +09:00]] 版)
<https://github.com/whatwg/html/commit/baa8e346d737c115d4a676caa4a172983b87255e>

[17] [CITE@en[Editorial: add "shadow host" and "assigned" as terms · whatwg/dom@8ae8749]]
([TIME[2016-04-21 12:48:26 +09:00]] 版)
<https://github.com/whatwg/dom/commit/8ae87496beb249925a3a72cf62aee9987e3620eb>

[23] [CITE@en['''['''css-scoping''']''' Remove 'shadow host' dfn, since DOM now defines it.]]
( ([[tabatkins]]著, [TIME[2016-05-11 07:28:13 +09:00]]))
<https://github.com/w3c/csswg-drafts/commit/c9945a5561d4b7a4e2ec14ec866b8d1b84708d83>