[4] [CODE(DOMi)@en[[[Node]]]] の [DFN[[CODE(DOMa)@en[[[ownerDocument]]]] [[属性]]]]は、
[CODE(DOMi)@en[[[Document]]]] では [[null]] を、それ以外では[[節点文書]]を返します [SRC[>>2]]。

* 仕様書

[REFS[
- [2] [CITE@en-US[DOM Standard]] ([TIME[2012-11-23 14:12:13 +09:00]] 版) <http://dom.spec.whatwg.org/#dom-node-ownerdocument>
- [5] [CITE@en-US[DOM Standard]] ([TIME[2012-11-23 14:12:13 +09:00]] 版) <http://dom.spec.whatwg.org/#concept-node-document>
]REFS]

* 取得器

[15] [CODE(DOMi)@en[[[Node]]]] [[インターフェイス]]の [CODE(DOMa)@en[[[ownerDocument]]]]
[[IDL属性]]の型は [CODE(IDL)@en[[[Document]][[?]]]] です [SRC[>>2]]。

[16] [[節点]]が[[文書]]なら、 [[null]] を返さなければ[['''なりません''']] [SRC[>>2]]。

[17] [[節点]]が[[文書]]以外なら、[[節点文書]]を返さなければ[['''なりません''']]
[SRC[>>2]]。

;; [18] 常に[[節点文書]]を返さないのは歴史的理由です。

* 節点文書

[6] [[節点]]は作成時に[DFN[[RUBYB[節点文書]@en[node document]]]]が関連付けられます [SRC[>>5]]。

;; [7] [[節点文書]]と [CODE(DOMa)@en[[[ownerDocument]]]] は、 [CODE(DOMi)@en[[[Document]]]]
においてのみ異なる値になります。

[10] [[節点文書]]を変更する操作は[[養子化]] ([[adopt]]) と呼ばれています。詳しくは [[adopt]]
の項を参照してください。

;; [14] それ以外で [CODE(DOMa)@en[[[ownerDocument]]]] や[[節点文書]]が変化することはありません。

;; [19] すべての[[節点]]は、[[節点文書]]を持ちます。[[文書]]と[[節点]]が同じ[[木]]に属さないとしても、
常に[[節点文書]]は存在しています。

* 歴史

** W3C DOM

[1]
[CODE(DOMa)@en[[[ownerDocument]]]]が[CODE(DOM)@en[[[null]]]]になるのは、[CODE(DOMi)@en[[[Document]]]][[節点]]自体の場合と、[CODE(DOMm)@en[[[createDocumentType]]]]してからまだ使用していない[CODE(DOMi)@en[[[DocumentType]]]][[節点]]の場合です。

[CODE(DOMi)@en[[[createDocumentType]]]]は[CODE(DOMi)@en[[[Entity]]]][[節点]]も[CODE(DOMi)@en[[[Notation]]]][[節点]]も含まない[[空]]の[[文書型]]を作ると定義されているので、それ以外の種類の[[節点]]で[CODE(DOMa)@en[[[ownerDocument]]]]が[CODE(DOM)@en[[[null]]]]になることはありません。

[8] [CITE@en-US[Document Object Model (DOM) Level 3 XPath Specification]]
( ([TIME[2004-02-23 21:49:04 +09:00]] 版))
<http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226/DOM3-XPath.html#xpath-XPathNamespace>

** DOM4

[3] [[DOM Living Standard]] では [CODE(DOMm)@en[[[createDocumentType]]]] はその 
[CODE(DOMi)@en[[[DOMImplementation]]]] [[オブジェクト]]と関連付けられている
[CODE(DOMi)@en[[[Document]]]] [[オブジェクト]]の [CODE(DOMi)@en[[[DocumentType]]]]
を作ることになっているため、その [CODE(DOMa)@en[[[ownerDocument]]]] は
[[null]] ではなく、必ず [CODE(DOMi)@en[[[Document]]]] となるようになりました。

[9] [CITE@en[Web Applications 1.0 r8270     Share the ownerDocument of template contents amongst the templates of a document.]]
( ([TIME[2013-11-13 06:36:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8269&to=8270>

[12] [[HTML Standard]] では [[DOM Standard]] 以前から
「[[節点]]の [CODE(DOMi)@en[[[Document]]]]」や
「[[属性]]の [CODE(DOMi)@en[[[Document]]]]」 といった用語が使われていましたが、
後に[[節点文書]]に統一されました [SRC[>>11, >>13]]。

[REFS[
- [11] [CITE@en[Web Applications 1.0 r8742 Make use of the DOM spec's 'node document' concept. I sure would appreciate careful review of this diff, since it is quite likely that I made some mistakes.]] ([TIME[2014-09-05 06:16:00 +09:00]] 版) <http://html5.org/r/8742>
- [13] [CITE@en[Sync with http://html5.org/r/8742 (Make use of the DOM spec's 'node docu... · 78818aa · ResponsiveImagesCG/picture-element]] ([TIME[2014-09-09 03:45:53 +09:00]] 版) <https://github.com/ResponsiveImagesCG/picture-element/commit/78818aa6a3975b22fa01033fcbfb6d9b19515081>
]REFS]

[20] [CITE@en[not in the same tree: use node document over ownerDocument attribute]]
([[andreastt]]著, [TIME[2017-08-31 07:49:13 +09:00]])
<https://github.com/w3c/webdriver/commit/897ea11f992db15e55287c132b0b7db01e7a7281>

[21] [CITE@en[not in the same tree: use node document over ownerDocument attribute by andreastt · Pull Request #1074 · w3c/webdriver]]
([TIME[2017-08-31 19:04:21 +09:00]])
<https://github.com/w3c/webdriver/pull/1074>

[22] [CITE@en[Replace prose about `ownerDocument` tree with DOM4 concept of `connec…]]
([[patrickhlauke]]著, [TIME[2018-04-03 23:25:20 +09:00]])
<https://github.com/w3c/pointerevents/commit/8f71ae0bab7afb9cb5785b8650228b7b06dd5452>

[23] [CITE@en[Replace prose about `ownerDocument` tree with DOM4 concept of `connected` by patrickhlauke · Pull Request #246 · w3c/pointerevents]]
([TIME[2018-05-09 12:09:44 +09:00]])
<https://github.com/w3c/pointerevents/pull/246>

[24] [CITE@en[Should setPointerCapture work in Shadow DOM · Issue #221 · w3c/pointerevents]]
([TIME[2018-05-09 12:10:04 +09:00]])
<https://github.com/w3c/pointerevents/issues/221>