-
Notifications
You must be signed in to change notification settings - Fork 22.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Demix ChildNode.replaceWith to Element, CharacterData, DocumentType (#…
- Loading branch information
Showing
9 changed files
with
231 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
title: CharacterData.replaceWith() | ||
slug: Web/API/CharacterData/replaceWith | ||
tags: | ||
- API | ||
- DOM | ||
- Method | ||
- CharacterData | ||
- Reference | ||
browser-compat: api.CharacterData.replaceWith | ||
--- | ||
<div>{{APIRef("DOM")}}</div> | ||
|
||
<p>The <code><strong>CharacterData.replaceWith()</strong></code> method replaces characters | ||
in the children list of its parent with a set of {{domxref("Node")}} or {{domxref("DOMString")}} objects. | ||
{{domxref("DOMString")}} objects are inserted as equivalent {{domxref("Text")}} nodes.</p> | ||
|
||
<h2 id="Syntax">Syntax</h2> | ||
|
||
<pre class="brush: js">replaceWith(...nodes)</pre> | ||
|
||
<h3 id="Parameters">Parameters</h3> | ||
|
||
<dl> | ||
<dt><code>nodes</code></dt> | ||
<dd>A set of {{domxref("Node")}} or {{domxref("DOMString")}} objects to replace.</dd> | ||
</dl> | ||
|
||
<h3 id="Exceptions">Exceptions</h3> | ||
|
||
<ul> | ||
<li>{{domxref("HierarchyRequestError")}}: Node cannot be inserted at the specified point | ||
in the hierarchy.</li> | ||
</ul> | ||
|
||
<h2 id="Examples">Examples</h2> | ||
|
||
<h3 id="Using_replaceWith">Using <code>replaceWith()</code></h3> | ||
|
||
<pre class="brush: html"> | ||
<p id="myText">Some text</p> | ||
</pre> | ||
|
||
<pre class="brush: js">let text = document.getElementById('myText').firstChild; | ||
text.replaceWith("Other text"); | ||
</pre> | ||
|
||
<pre class="brush: html"> | ||
<p id="myText">Other text</p> | ||
</pre> | ||
|
||
<h2 id="Specifications">Specifications</h2> | ||
|
||
<p>{{Specifications}} | ||
|
||
</p> | ||
<h2 id="Browser_compatibility">Browser compatibility</h2> | ||
|
||
<p>{{Compat}}</p> | ||
|
||
<h2 id="See_also">See also</h2> | ||
|
||
<ul> | ||
<li>{{domxref("CharacterData.replaceData()")}}</li> | ||
</ul> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
title: DocumentType.replaceWith() | ||
slug: Web/API/DocumentType/replaceWith | ||
tags: | ||
- API | ||
- DOM | ||
- Method | ||
- DocumentType | ||
- Reference | ||
browser-compat: api.DocumentType.replaceWith | ||
--- | ||
<div>{{APIRef("DOM")}}</div> | ||
|
||
<p>The <code><strong>DocumentType.replaceWith()</strong></code> method replaces the document type with a set of given nodes.</p> | ||
|
||
<h2 id="Syntax">Syntax</h2> | ||
|
||
<pre class="brush: js">replaceWith(...nodes)</pre> | ||
|
||
<h3 id="Parameters">Parameters</h3> | ||
|
||
<dl> | ||
<dt><code>nodes</code></dt> | ||
<dd>A set of nodes to replace the {{domxref("DocumentType")}} with.</dd> | ||
</dl> | ||
|
||
<h3 id="Exceptions">Exceptions</h3> | ||
|
||
<ul> | ||
<li>{{domxref("HierarchyRequestError")}}: Node cannot be inserted at the specified point | ||
in the hierarchy.</li> | ||
</ul> | ||
|
||
<h2 id="Examples">Examples</h2> | ||
|
||
<h3 id="Using_replaceWith">Using <code>replaceWith()</code></h3> | ||
|
||
<pre class="brush: js"> | ||
let svg_dt = document.implementation.createDocumentType( | ||
'svg:svg', | ||
'-//W3C//DTD SVG 1.1//EN', | ||
'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' | ||
); | ||
|
||
document.doctype.replaceWith(svg_dt); | ||
</pre> | ||
|
||
<h2 id="Specifications">Specifications</h2> | ||
|
||
<p>{{Specifications}} | ||
|
||
</p> | ||
<h2 id="Browser_compatibility">Browser compatibility</h2> | ||
|
||
<p>{{Compat}}</p> | ||
|
||
<h2 id="See_also">See also</h2> | ||
|
||
<ul> | ||
<li>{{domxref("Element.replaceWith()")}}</li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.