Skip to content

Commit

Permalink
Demix Parentnode.children to Element, Document, DocumentFragment pages (
Browse files Browse the repository at this point in the history
mdn#4065)

* yarn content move Web/API/ParentNode/children Web/API/Element/children

* Update Element.children

* Add children to Element interface listing

* Update Document and DocumentFragment interface pages

* Add docs for DocumentFragment.children

* Add docs for Document.children

* Add a usage note on Element.children vs Node.childNodes

* Update links

* Remove redirects for now existing pages
  • Loading branch information
Elchi3 authored Apr 13, 2021
1 parent cfc5f76 commit 61f767f
Show file tree
Hide file tree
Showing 10 changed files with 263 additions and 145 deletions.
12 changes: 5 additions & 7 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@
/en-US/docs/DOM/DocumentType /en-US/docs/Web/API/DocumentType
/en-US/docs/DOM/DynamicsCompressorNode /en-US/docs/Web/API/DynamicsCompressorNode
/en-US/docs/DOM/Element.childElementCount /en-US/docs/Web/API/Element/childElementCount
/en-US/docs/DOM/Element.children /en-US/docs/Web/API/ParentNode/children
/en-US/docs/DOM/Element.children /en-US/docs/Web/API/Element/children
/en-US/docs/DOM/Element.contentEditable /en-US/docs/Web/API/HTMLElement/contentEditable
/en-US/docs/DOM/Element.firstElementChild /en-US/docs/Web/API/ParentNode/firstElementChild
/en-US/docs/DOM/Element.getElementsByClassName /en-US/docs/Web/API/Element/getElementsByClassName
Expand Down Expand Up @@ -2970,7 +2970,7 @@
/en-US/docs/Document_Object_Model_(DOM)/DocumentTouch.createTouchList /en-US/docs/Web/API/Document/createTouchList
/en-US/docs/Document_Object_Model_(DOM)/DocumentType /en-US/docs/Web/API/DocumentType
/en-US/docs/Document_Object_Model_(DOM)/Element.childElementCount /en-US/docs/Web/API/Element/childElementCount
/en-US/docs/Document_Object_Model_(DOM)/Element.children /en-US/docs/Web/API/ParentNode/children
/en-US/docs/Document_Object_Model_(DOM)/Element.children /en-US/docs/Web/API/Element/children
/en-US/docs/Document_Object_Model_(DOM)/Element.contentEditable /en-US/docs/Web/API/HTMLElement/contentEditable
/en-US/docs/Document_Object_Model_(DOM)/Element.firstElementChild /en-US/docs/Web/API/ParentNode/firstElementChild
/en-US/docs/Document_Object_Model_(DOM)/Element.getElementsByClassName /en-US/docs/Web/API/Element/getElementsByClassName
Expand Down Expand Up @@ -7505,7 +7505,6 @@
/en-US/docs/Web/API/Document/baseURI /en-US/docs/Web/API/Node/baseURI
/en-US/docs/Web/API/Document/cancelFullscreen /en-US/docs/Web/API/Document/exitFullscreen
/en-US/docs/Web/API/Document/charset /en-US/docs/Web/API/document/characterSet
/en-US/docs/Web/API/Document/children /en-US/docs/Web/API/ParentNode/children
/en-US/docs/Web/API/Document/defaultView/popstate_event /en-US/docs/Web/API/Window/popstate_event
/en-US/docs/Web/API/Document/defaultView/resize_event /en-US/docs/Web/API/Window/resize_event
/en-US/docs/Web/API/Document/defaultView/storage_event /en-US/docs/Web/API/Window/storage_event
Expand Down Expand Up @@ -7545,7 +7544,6 @@
/en-US/docs/Web/API/DocumentFragment.DocumentFragment /en-US/docs/Web/API/DocumentFragment/DocumentFragment
/en-US/docs/Web/API/DocumentFragment.querySelector /en-US/docs/Web/API/DocumentFragment/querySelector
/en-US/docs/Web/API/DocumentFragment.querySelectorAll /en-US/docs/Web/API/DocumentFragment/querySelectorAll
/en-US/docs/Web/API/DocumentFragment/children /en-US/docs/Web/API/ParentNode/children
/en-US/docs/Web/API/DocumentFragment/firstElementChild /en-US/docs/Web/API/ParentNode/firstElementChild
/en-US/docs/Web/API/DocumentFragment/lastElementChild /en-US/docs/Web/API/ParentNode/lastElementChild
/en-US/docs/Web/API/DocumentOrShadowRoot/activeElement /en-US/docs/Web/API/Document/activeElement
Expand Down Expand Up @@ -7575,7 +7573,7 @@
/en-US/docs/Web/API/DynamicsCompressorNode.threshold /en-US/docs/Web/API/DynamicsCompressorNode/threshold
/en-US/docs/Web/API/Element.attributes /en-US/docs/Web/API/Element/attributes
/en-US/docs/Web/API/Element.childElementCount /en-US/docs/Web/API/Element/childElementCount
/en-US/docs/Web/API/Element.children /en-US/docs/Web/API/ParentNode/children
/en-US/docs/Web/API/Element.children /en-US/docs/Web/API/Element/children
/en-US/docs/Web/API/Element.clientLeft /en-US/docs/Web/API/Element/clientLeft
/en-US/docs/Web/API/Element.clientTop /en-US/docs/Web/API/Element/clientTop
/en-US/docs/Web/API/Element.closest /en-US/docs/Web/API/Element/closest
Expand Down Expand Up @@ -7613,7 +7611,6 @@
/en-US/docs/Web/API/Element/animationiteration_event /en-US/docs/Web/API/HTMLElement/animationiteration_event
/en-US/docs/Web/API/Element/animationstart_event /en-US/docs/Web/API/HTMLElement/animationstart_event
/en-US/docs/Web/API/Element/cancel_event /en-US/docs/Web/API/HTMLDialogElement/cancel_event
/en-US/docs/Web/API/Element/children /en-US/docs/Web/API/ParentNode/children
/en-US/docs/Web/API/Element/firstElementChild /en-US/docs/Web/API/ParentNode/firstElementChild
/en-US/docs/Web/API/Element/fullscreenchange /en-US/docs/Web/API/Element/fullscreenchange_event
/en-US/docs/Web/API/Element/gotpointercapture_event /en-US/docs/Web/API/HTMLElement/gotpointercapture_event
Expand Down Expand Up @@ -8463,10 +8460,11 @@
/en-US/docs/Web/API/PannerNode.setPosition /en-US/docs/Web/API/PannerNode/setPosition
/en-US/docs/Web/API/PannerNode.setVelocity /en-US/docs/Web/API/PannerNode/setVelocity
/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/ParentNode/children
/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/ParentNode/firstElementChild
/en-US/docs/Web/API/ParentNode.lastElementChild /en-US/docs/Web/API/ParentNode/lastElementChild
/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/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
58 changes: 29 additions & 29 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -71025,35 +71025,6 @@
"fscholz"
]
},
"Web/API/ParentNode/children": {
"modified": "2020-10-15T21:05:52.672Z",
"contributors": [
"Zearin_Galaurum",
"mfluehr",
"ExE-Boss",
"Sheppy",
"Pbb",
"jackblackevo",
"Delapouite",
"idontusenumbers",
"K-Gun",
"jonkee",
"vedmack",
"Robg1",
"fscholz",
"Prome",
"ziyunfei",
"danburzo",
"Kartik_Chadha",
"teoli",
"Krinkle",
"Dan-Dascalescu",
"fryn",
"Philip Chee",
"paul.irish",
"janmoesen"
]
},
"Web/API/ParentNode/firstElementChild": {
"modified": "2020-10-15T21:06:48.193Z",
"contributors": [
Expand Down Expand Up @@ -165633,5 +165604,34 @@
"ziyunfei",
"Jürgen Jeka"
]
},
"Web/API/Element/children": {
"modified": "2020-10-15T21:05:52.672Z",
"contributors": [
"Zearin_Galaurum",
"mfluehr",
"ExE-Boss",
"Sheppy",
"Pbb",
"jackblackevo",
"Delapouite",
"idontusenumbers",
"K-Gun",
"jonkee",
"vedmack",
"Robg1",
"fscholz",
"Prome",
"ziyunfei",
"danburzo",
"Kartik_Chadha",
"teoli",
"Krinkle",
"Dan-Dascalescu",
"fryn",
"Philip Chee",
"paul.irish",
"janmoesen"
]
}
}
76 changes: 76 additions & 0 deletions files/en-us/web/api/document/children/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: Document.children
slug: Web/API/Document/children
tags:
- API
- DOM
- Element
- HTMLCollection
- Property
- children
---
<div>{{ APIRef("DOM") }}</div>

<p>The read-only <code><strong>children</strong></code> property returns a live {{domxref("HTMLCollection")}}
which contains all of the child {{domxref("Element", "elements")}} of the document upon which it was called.</p>

<p>For HTML documents, this is usually only the root <code>&lt;html&gt;</code> element.</p>

<p>See {{domxref("Element.children")}} for child elements of specific HTML elements within the document.</p>

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

<pre class="brush: js">
// Getter
collection = document.children;

// No setter; read-only property
</pre>

<h3 id="Return_value">Return value</h3>

<p>An {{ domxref("HTMLCollection") }} which is a live, ordered collection of the DOM
elements which are children of the current document. You can access the
individual child nodes in the collection by using either the
{{domxref("HTMLCollection.item()", "item()")}} method on the collection, or by using
JavaScript array-style notation.</p>

<p>If the document has no element children, then <code>children</code> is an empty list with a
<code>length</code> of <code>0</code>.</p>

<h2 id="Example">Example</h2>

<pre class="brush: js">
document.children;
// HTMLCollection [&lt;html&gt;]
// Usually only contains the root &lt;html&gt; element, the document's only direct child
</pre>

<p>See {{domxref("Element.children")}} for child elements of specific HTML elements within the document.</p>


<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-children', 'ParentNode.children')}}</td>
</tr>
</tbody>
</table>

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

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

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

<ul>
<li>{{domxref("Element.children")}}</li>
<li>{{domxref("Node.childNodes")}}</li>
</ul>
2 changes: 2 additions & 0 deletions files/en-us/web/api/document/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ <h2 id="Properties">Properties</h2>
<dd>Returns the character set being used by the document.</dd>
<dt>{{domxref("Document.childElementCount")}} {{readonlyInline}}</dt>
<dd>Returns the number of child elements of the current document.</dd>
<dt>{{domxref("Document.children")}} {{readonlyInline}}</dt>
<dd>Returns the child elements of the current document.</dd>
<dt>{{DOMxRef("Document.compatMode")}} {{Experimental_Inline}}{{ReadOnlyInline}}</dt>
<dd>Indicates whether the document is rendered in <em>quirks</em> or <em>strict</em> mode.</dd>
<dt>{{DOMxRef("Document.contentType")}} {{Experimental_Inline}}{{ReadOnlyInline}}</dt>
Expand Down
74 changes: 74 additions & 0 deletions files/en-us/web/api/documentfragment/children/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: DocumentFragment.children
slug: Web/API/DocumentFragment/children
tags:
- API
- DOM
- Element
- HTMLCollection
- Property
- children
---
<div>{{ APIRef("DOM") }}</div>

<p>The read-only <code><strong>children</strong></code> property returns a live {{domxref("HTMLCollection")}}
which contains all of the child {{domxref("Element", "elements")}} of the document fragment upon which it was called.</p>

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

<pre class="brush: js">
// Getter
collection = myFragment.children;

// No setter; read-only property
</pre>

<h3 id="Return_value">Return value</h3>

<p>An {{ domxref("HTMLCollection") }} which is a live, ordered collection of the DOM
elements which are children of the document fragment. You can access the
individual child nodes in the collection by using either the
{{domxref("HTMLCollection.item()", "item()")}} method on the collection, or by using
JavaScript array-style notation.</p>

<p>If the document fragment has no element children, then <code>children</code> is an empty list with a
<code>length</code> of <code>0</code>.</p>

<h2 id="Example">Example</h2>

<pre class="brush: js">
let fragment = new DocumentFragment()
fragment.children; // HTMLCollection []

let paragraph = document.createElement('p')
fragment.appendChild(paragraph)

fragment.children; // HTMLCollection [&lt;p&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-children', 'ParentNode.children')}}</td>
</tr>
</tbody>
</table>

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

<p>{{Compat("api.DocumentFragment.children")}}</p>

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

<ul>
<li>
{{domxref("Node.childNodes")}}
</li>
</ul>
2 changes: 1 addition & 1 deletion files/en-us/web/api/documentfragment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h2 id="Properties">Properties</h2>
<dl>
<dt>{{ domxref("DocumentFragment.childElementCount") }} {{readonlyInline}} </dt>
<dd>Returns the amount of child {{domxref("Element","elements")}} the <code>DocumentFragment</code> has.</dd>
<dt>{{ domxref("ParentNode.children") }} {{readonlyInline}}{{experimental_inline}}</dt>
<dt>{{ domxref("DocumentFragment.children") }} {{readonlyInline}}</dt>
<dd>Returns a live {{domxref("HTMLCollection")}} containing all objects of type {{domxref("Element")}} that are children of the <code>DocumentFragment</code> object.</dd>
<dt>{{ domxref("ParentNode.firstElementChild") }} {{readonlyInline}}{{experimental_inline}}</dt>
<dd>Returns the {{domxref("Element")}} that is the first child of the <code>DocumentFragment</code> object, or <code>null</code> if there is none.</dd>
Expand Down
72 changes: 72 additions & 0 deletions files/en-us/web/api/element/children/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: Element.children
slug: Web/API/Element/children
tags:
- API
- DOM
- Element
- HTMLCollection
- Property
- children
---
<div>{{ APIRef("DOM") }}</div>

<p>The read-only <code><strong>children</strong></code> property returns a live {{domxref("HTMLCollection")}}
which contains all of the child {{domxref("Element", "elements")}} of the element upon which it was called.</p>

<p><code>Element.children</code> includes only element nodes. To get all child nodes, including non-element nodes like text and comment nodes, use {{domxref("Node.childNodes")}}.</p>

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

<pre class="brush: js">
// Getter
collection = myElement.children;

// No setter; read-only property
</pre>

<h3 id="Return_value">Return value</h3>

<p>An {{ domxref("HTMLCollection") }} which is a live, ordered collection of the DOM
elements which are children of <code><var>node</var></code>. You can access the
individual child nodes in the collection by using either the
{{domxref("HTMLCollection.item()", "item()")}} method on the collection, or by using
JavaScript array-style notation.</p>

<p>If the element has no element children, then <code>children</code> is an empty list with a
<code>length</code> of <code>0</code>.</p>

<h2 id="Example">Example</h2>

<pre class="brush: js">const myElement = document.getElementById('foo');
for (let i = 0; i &lt; myElement.children.length; i++) {
console.log(myElement.children[i].tagName);
}
</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-children', 'ParentNode.children')}}</td>
</tr>
</tbody>
</table>

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

<p>{{Compat("api.Element.children")}}</p>

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

<ul>
<li>
{{domxref("Node.childNodes")}}
</li>
</ul>
2 changes: 2 additions & 0 deletions files/en-us/web/api/element/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ <h2 id="Properties">Properties</h2>
<dd>Returns a {{DOMxRef("NamedNodeMap")}} object containing the assigned attributes of the corresponding HTML element.</dd>
<dt>{{domxref("Element.childElementCount")}} {{readonlyInline}}</dt>
<dd>Returns the number of child elements of this element.</dd>
<dt>{{domxref("Element.children")}} {{readonlyInline}}</dt>
<dd>Returns the child elements of this element.</dd>
<dt>{{DOMxRef("Element.classList")}} {{readOnlyInline}}</dt>
<dd>Returns a {{DOMxRef("DOMTokenList")}} containing the list of class attributes.</dd>
<dt>{{DOMxRef("Element.className")}}</dt>
Expand Down
Loading

0 comments on commit 61f767f

Please sign in to comment.