Skip to content

Commit

Permalink
Demix Parentnode.{append,prepend} to Element, Document, DocumentFragm…
Browse files Browse the repository at this point in the history
…ent pages (#4163)

* Move ParentNode.append to Element.append and update Element.append

* Update Element method list to add append

* Add Document.append

* Add DocumentFragment.append

* Update links to ParentNode.append and ParentNode.prepend

* Move ParentNode.prepend to Element.prepend and update Element.prepend

* Add Document.prepend

* Add DocumentFragment.prepend page
  • Loading branch information
Elchi3 committed Apr 16, 2021
1 parent c0e530c commit bd5cb71
Show file tree
Hide file tree
Showing 19 changed files with 625 additions and 351 deletions.
2 changes: 2 additions & 0 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8457,10 +8457,12 @@
/en-US/docs/Web/API/ParentNode.children /en-US/docs/Web/API/Element/children
/en-US/docs/Web/API/ParentNode.firstElementChild /en-US/docs/Web/API/Element/firstElementChild
/en-US/docs/Web/API/ParentNode.lastElementChild /en-US/docs/Web/API/Element/lastElementChild
/en-US/docs/Web/API/ParentNode/append /en-US/docs/Web/API/Element/append
/en-US/docs/Web/API/ParentNode/childElementCount /en-US/docs/Web/API/Element/childElementCount
/en-US/docs/Web/API/ParentNode/children /en-US/docs/Web/API/Element/children
/en-US/docs/Web/API/ParentNode/firstElementChild /en-US/docs/Web/API/Element/firstElementChild
/en-US/docs/Web/API/ParentNode/lastElementChild /en-US/docs/Web/API/Element/lastElementChild
/en-US/docs/Web/API/ParentNode/prepend /en-US/docs/Web/API/Element/prepend
/en-US/docs/Web/API/PasswordCredential/additionalData /en-US/docs/Web/API/PasswordCredential
/en-US/docs/Web/API/PasswordCredential/idName /en-US/docs/Web/API/PasswordCredential
/en-US/docs/Web/API/PasswordCredential/passwordName /en-US/docs/Web/API/PasswordCredential
Expand Down
84 changes: 42 additions & 42 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -71004,48 +71004,6 @@
"teoli"
]
},
"Web/API/ParentNode/append": {
"modified": "2020-11-27T11:36:02.538Z",
"contributors": [
"TrevorKarjanis",
"mfuji09",
"beingmrkenny",
"Zearin_Galaurum",
"timtim17",
"matthewp",
"mfluehr",
"ExE-Boss",
"raidiun",
"stevenwdv",
"Delapouite",
"gretencord",
"jszhou",
"valtlai",
"jpmedley",
"fscholz"
]
},
"Web/API/ParentNode/prepend": {
"modified": "2020-11-27T11:36:17.341Z",
"contributors": [
"TrevorKarjanis",
"mfuji09",
"beingmrkenny",
"sideshowbarker",
"rysmax",
"matthewp",
"mfluehr",
"krosylight",
"ExE-Boss",
"merih",
"stevenwdv",
"CollinGrimm",
"Sheppy",
"jszhou",
"jpmedley",
"fscholz"
]
},
"Web/API/ParentNode/querySelector": {
"modified": "2020-10-15T22:11:25.046Z",
"contributors": [
Expand Down Expand Up @@ -165623,5 +165581,47 @@
"Midnightaz",
"hamishwillee"
]
},
"Web/API/Element/append": {
"modified": "2020-11-27T11:36:02.538Z",
"contributors": [
"TrevorKarjanis",
"mfuji09",
"beingmrkenny",
"Zearin_Galaurum",
"timtim17",
"matthewp",
"mfluehr",
"ExE-Boss",
"raidiun",
"stevenwdv",
"Delapouite",
"gretencord",
"jszhou",
"valtlai",
"jpmedley",
"fscholz"
]
},
"Web/API/Element/prepend": {
"modified": "2020-11-27T11:36:17.341Z",
"contributors": [
"TrevorKarjanis",
"mfuji09",
"beingmrkenny",
"sideshowbarker",
"rysmax",
"matthewp",
"mfluehr",
"krosylight",
"ExE-Boss",
"merih",
"stevenwdv",
"CollinGrimm",
"Sheppy",
"jszhou",
"jpmedley",
"fscholz"
]
}
}
3 changes: 1 addition & 2 deletions files/en-us/web/api/childnode/after/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,8 @@ <h2 id="Browser_compatibility">Browser compatibility</h2>
<h2 id="See_also">See also</h2>

<ul>
<li>{{domxref("ChildNode")}} and {{domxref("ParentNode")}}</li>
<li>{{domxref("ChildNode.before()")}}</li>
<li>{{domxref("ParentNode.append()")}}</li>
<li>{{domxref("Element.append()")}}</li>
<li>{{domxref("Node.appendChild()")}}</li>
<li>{{domxref("Element.insertAdjacentElement()")}}</li>
<li>{{domxref("NodeList")}}</li>
Expand Down
3 changes: 1 addition & 2 deletions files/en-us/web/api/childnode/before/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ <h2 id="Browser_compatibility">Browser compatibility</h2>
<h2 id="See_also">See also</h2>

<ul>
<li>{{domxref("ChildNode")}} and {{domxref("ParentNode")}}</li>
<li>{{domxref("ChildNode.after()")}}</li>
<li>{{domxref("ParentNode.append()")}}</li>
<li>{{domxref("Element.append()")}}</li>
<li>{{domxref("Node.appendChild()")}}</li>
<li>{{domxref("Node.insertBefore()")}}</li>
<li>{{domxref("Element.insertAdjacentElement()")}}</li>
Expand Down
88 changes: 88 additions & 0 deletions files/en-us/web/api/document/append/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
title: Document.append()
slug: Web/API/Document/append
tags:
- API
- DOM
- Method
- Node
- Document
- Reference
---
<p>{{APIRef("DOM")}}</p>

<p>The <strong><code>Document.append()</code></strong> method
inserts a set of {{domxref("Node")}} objects or {{domxref("DOMString")}} objects after
the last child of the document. </span>{{domxref("DOMString")}} objects
are inserted as equivalent {{domxref("Text")}} nodes.</p>

<p>This method appends a child to a <code>Document</code>. To append to an arbitrary element in the tree, see {{domxref("Element.append()")}}.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="brush: js">
append(...nodesOrDOMStrings)
</pre>

<h3 id="Parameters">Parameters</h3>

<dl>
<dt><code>nodesOrDOMStrings</code></dt>
<dd>A set of {{domxref("Node")}} or {{domxref("DOMString")}} objects to insert.</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="Appending_a_root_element_to_a_document">Appending a root element to a document</h3>

<p>If you try to append an element to an existing HTML document,
it might throw a {{domxref("HierarchyRequestError")}} given a {{HTMLElement("html")}} element already exists.</p>

<pre class="brush: js">
let html = document.createElement("html");
document.append(html);
// HierarchyRequestError: The operation would yield an incorrect node tree.
</pre>

<p>If you are creating a new document without any existing element, you can append a root HTML element (or a root SVG element):</p>

<pre class="brush: js">
let doc = new Document();
let html = document.createElement("html");
doc.append(html);

doc.children; // HTMLCollection [&lt;html&gt;]
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('DOM WHATWG', '#dom-parentnode-append', 'ParentNode.append()')}}</td>
</tr>
</tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{Compat("api.Document.append")}}</p>

<h2 id="See_also">See also</h2>

<ul>
<li>{{domxref("Document.prepend()")}}</li>
<li>{{domxref("Element.append()")}}</li>
</ul>
4 changes: 4 additions & 0 deletions files/en-us/web/api/document/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ <h2 id="Methods">Methods</h2>
<dl>
<dt>{{DOMxRef("Document.adoptNode()")}}</dt>
<dd>Adopt node from an external document.</dd>
<dt>{{DOMxRef("Document.append()")}}</dt>
<dd>Inserts a set of {{domxref("Node")}} objects or {{domxref("DOMString")}} objects after the last child of the document.</dd>
<dt>{{DOMxRef("Document.captureEvents()")}} {{Deprecated_Inline}}</dt>
<dd>See {{DOMxRef("Window.captureEvents")}}.</dd>
<dt>{{DOMxRef("Document.caretPositionFromPoint()")}}</dt>
Expand Down Expand Up @@ -272,6 +274,8 @@ <h2 id="Methods">Methods</h2>
<dd>Returns a clone of a node from an external document.</dd>
<dt>{{DOMxRef("Document.normalizeDocument()")}} {{Obsolete_Inline}}</dt>
<dd>Replaces entities, normalizes text nodes, etc.</dd>
<dt>{{DOMxRef("Document.prepend()")}}</dt>
<dd>Inserts a set of {{domxref("Node")}} objects or {{domxref("DOMString")}} objects before the first child of the document.</dd>
<dt>{{DOMxRef("Document.releaseCapture()")}} {{Non-standard_Inline}}</dt>
<dd>Releases the current mouse capture if it's on an element in this document.</dd>
<dt>{{DOMxRef("Document.releaseEvents()")}} {{Non-standard_Inline}} {{Deprecated_Inline}}</dt>
Expand Down
88 changes: 88 additions & 0 deletions files/en-us/web/api/document/prepend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
title: Document.prepend()
slug: Web/API/Document/prepend
tags:
- API
- DOM
- Method
- Node
- Document
- Reference
---
<p>{{APIRef("DOM")}}</p>

<p>The <strong><code>Document.prepend()</code></strong> method
inserts a set of {{domxref("Node")}} objects or {{domxref("DOMString")}} objects before
the first child of the document. </span>{{domxref("DOMString")}} objects
are inserted as equivalent {{domxref("Text")}} nodes.</p>

<p>This method prepends a child to a <code>Document</code>. To prepend to an arbitrary element in the tree, see {{domxref("Element.prepend()")}}.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="brush: js">
prepend(...nodesOrDOMStrings)
</pre>

<h3 id="Parameters">Parameters</h3>

<dl>
<dt><code>nodesOrDOMStrings</code></dt>
<dd>A set of {{domxref("Node")}} or {{domxref("DOMString")}} objects to insert.</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="Prepending_a_root_element_to_a_document">Prepending a root element to a document</h3>

<p>If you try to prepend an element to an existing HTML document,
it might throw a {{domxref("HierarchyRequestError")}} given a {{HTMLElement("html")}} element already exists.</p>

<pre class="brush: js">
let html = document.createElement("html");
document.prepend(html);
// HierarchyRequestError: The operation would yield an incorrect node tree.
</pre>

<p>If you are creating a new document without any existing element, you can prepend a root HTML element (or a root SVG element):</p>

<pre class="brush: js">
let doc = new Document();
let html = document.createElement("html");
doc.prepend(html);

doc.children; // HTMLCollection [&lt;html&gt;]
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('DOM WHATWG', '#dom-parentnode-prepend', 'ParentNode.prepend()')}}</td>
</tr>
</tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{Compat("api.Document.prepend")}}</p>

<h2 id="See_also">See also</h2>

<ul>
<li>{{domxref("Document.append()")}}</li>
<li>{{domxref("Element.prepend()")}}</li>
</ul>
Loading

0 comments on commit bd5cb71

Please sign in to comment.