* 仕様書

[REFS[
- [8] [CITE@en[DOM Standard]] ([TIME[2015-05-08 20:08:36 +09:00]] 版) <https://dom.spec.whatwg.org/#concept-node-replace>
- [9] [CITE@en[DOM Standard]] ([TIME[2015-05-08 20:08:36 +09:00]] 版) <https://dom.spec.whatwg.org/#concept-node-replace-all>
- [10] [CITE@en[DOM Standard]] ([TIME[2015-05-08 20:08:36 +09:00]] 版) <https://dom.spec.whatwg.org/#dom-node-replacechildnode-child>
- [12] [CITE@en[DOM Standard]] ([TIME[2015-05-08 20:08:36 +09:00]] 版) <https://dom.spec.whatwg.org/#dom-childnode-replacewithnodes>
]REFS]

* すべて置換

[19] [CODE[document.open]] では、[[変異イベント無効]]で呼び出されます。

* 歴史

[1]
[[DOM水準1]] [[SE]] と[[DOM水準2]]と[[DOM水準3]]によれば、
[CODE(DOMp)@en[[[newChild]]]] の [CODE(DOMa)@en[[[parentNode]]]]
が[[読取専用]]なら [CODE(DOMc)@en[[[NO_MODIFICATION_ALLOWED_ERR]]]] となります。
([[名無しさん]])

[2]

[CODE(DOMa)@en[[[ownerDocument]]]] が
[CODE(IDL)@en[[[nullll]]]]
の [CODE(DOMi)@en[[[DocumentType]]]]
を [CODE(DOMp)@en[[[newChild]]]] としたときどうなるのかよくわかりません。
([[名無しさん]])

[3]
[[DOM水準1]] [[SE]] と [[DOM水準2]]と[[DOM水準3]]によれば
[CODE(DOMi)@en[[[DocumentFragment]]]] とすると、
[CODE(DOMp)@en[[[oldChild]]]] は
[CODE(DOMi)@en[[[DocumentFragment]]]]
の[[子供]]達 (そのままの[[順序]]) により置き換えられます。
([[名無しさん]])

[4]
[[DOM水準3]]によると自分自身を置換しようとしたら結果は[[実装依存]]です。
([[名無しさん]])

[5]
[CODE(DOMi)@en[[[Document]]]] の[[子供]]の扱いについては
[CODE(DOMm)@en[[[appendChild]]]] を参照。

[6]
[[DOM水準2]][[正誤表]]と[[DOM水準3]]によると自分に自分を
[CODE(DOMm)@en[[[appendChild]]]] しようとしたら
[CODE(DOMc)@en[[[HIERARCHY_REQUEST_ERR]]]] です。

[206] [CITE[Issue 255482 - chromium - DOM4: prepend, append, before, after & replace - An open-source project to help move the web forward. - Google Project Hosting]]
( ([TIME[2014-11-26 12:42:46 +09:00]] 版))
<https://code.google.com/p/chromium/issues/detail?id=255482>

[207] [CITE@en[911477 – Implement DOM4 methods: prepend(), append(), before(), after() and replace()]]
( ([TIME[2014-11-26 12:43:36 +09:00]] 版))
<https://bugzilla.mozilla.org/show_bug.cgi?id=911477>

[208] [CITE@en[Mark new APIs as ''''''[''''''Unscopeable'''''']'''''' https://www.w3.org/Bugs/Public/show_bug.c... · b2eb25f · whatwg/dom]]
( ([TIME[2014-11-27 20:47:53 +09:00]] 版))
<https://github.com/whatwg/dom/commit/b2eb25f751cb71a6ffacebe714c27667d3591e6b>

[11] [CITE@en[Rename replace() to replaceWith() · b7563aa · whatwg/dom]] ([TIME[2015-01-15 11:43:22 +09:00]] 版) <https://github.com/whatwg/dom/commit/b7563aaf0864c8d104d18c36a9eda036c5205131>

[7] [CITE@en[Need to grab children of a DocumentFragment before an insert. Fixes h… · whatwg/dom@1b9e2f9]]
([TIME[2015-05-30 23:37:04 +09:00]] 版)
<https://github.com/whatwg/dom/commit/1b9e2f9765884460410d1396dbba99951eafe838>

[13] [CITE@en[Do not remove child from its parent when replacing a node by itself · whatwg/dom@c20e4b5]]
([TIME[2015-12-03 22:46:43 +09:00]] 版)
<https://github.com/whatwg/dom/commit/c20e4b558535b81cb5b36e77ab6ed12a102d0a00>

[14] [CITE@en[Close #128: fix a typo in the replace a node algorithm · whatwg/dom@f2b2a22]]
([TIME[2015-12-16 12:16:22 +09:00]] 版)
<https://github.com/whatwg/dom/commit/f2b2a221ddc9022988fc6ab7a73fce7a0d0d0071>

[15] [CITE@en[Editorial: synchronize with the DOM Standard · whatwg/html@21c6ec7]]
([TIME[2016-03-20 18:02:25 +09:00]] 版)
<https://github.com/whatwg/html/commit/21c6ec77594eb89b836d4872222f5916910967fd>

[16] [CITE@en[Add ''''''[''''''CEReactions'''''']'''''' annotations to mutating methods · whatwg/dom@3cd02d1]]
([TIME[2016-04-26 19:06:35 +09:00]] 版)
<https://github.com/whatwg/dom/commit/3cd02d139c159a31fbb400e03932652c72fc7812>

[17] [CITE@en[Add ''''''[''''''CEReactions'''''']'''''' annotations to mutating methods · whatwg/dom@3cd02d1]]
([TIME[2016-04-26 19:07:28 +09:00]] 版)
<https://github.com/whatwg/dom/commit/3cd02d139c159a31fbb400e03932652c72fc7812>

[18] [CITE@en[Use DOM's "replace all" primitive in document.open()]]
([[annevk]]著, [TIME[2018-05-01 01:44:29 +09:00]])
<https://github.com/whatwg/html/commit/423c66403522b09138dc3b366bf96111bc030a04>

[20] [CITE@en[Use DOM's "replace all" primitive in document.open() by annevk · Pull Request #3598 · whatwg/html]]
([TIME[2018-05-03 10:36:20 +09:00]])
<https://github.com/whatwg/html/pull/3598>