Skip to content

Commit edf65bf

Browse files
authored
Create an abstraction for Element's textContent
This is needed for defining HTML's output element and various other features in HTML. See whatwg/html#4163 for context.
1 parent 9943801 commit edf65bf

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

dom.bs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4113,11 +4113,7 @@ following, switching on <a>context object</a>:
41134113
<dl class=switch>
41144114
<dt>{{DocumentFragment}}
41154115
<dt>{{Element}}
4116-
<dd>The <a for=string>concatenation</a> of <a for=CharacterData>data</a> of all
4117-
the {{Text}} <a>node</a>
4118-
<a>descendants</a> of the
4119-
<a>context object</a>, in
4120-
<a>tree order</a>.
4116+
<dd>The <a>descendant text content</a> of the <a>context object</a>.
41214117

41224118
<dt>{{Attr}}
41234119
<dd><a>Context object</a>'s <a for=Attr>value</a>.
@@ -4131,22 +4127,26 @@ following, switching on <a>context object</a>:
41314127
<dd>Null.
41324128
</dl>
41334129

4130+
<p>To <dfn export>string replace all</dfn> with a string <var>string</var> within a
4131+
<a for=/>node</a> <var>parent</var>, run these steps:
4132+
4133+
<ol>
4134+
<li><p>Let <var>node</var> be null.
4135+
4136+
<li><p>If <var>string</var> is not the empty string, then set <var>node</var> to a new {{Text}}
4137+
<a for=/>node</a> whose <a for=CharacterData>data</a> is <var>string</var> and
4138+
<a for=Node>node document</a> is <var>parent</var>'s <a for=Node>node document</a>.
4139+
4140+
<li><p><a for=Node>Replace all</a> with <var>node</var> within <var>parent</var>.
4141+
</ol>
4142+
41344143
<p>The {{Node/textContent}} attribute's setter must, if the given value is null, act as if it was
41354144
the empty string instead, and then do as described below, switching on <a>context object</a>:
41364145

41374146
<dl class=switch>
41384147
<dt>{{DocumentFragment}}
41394148
<dt>{{Element}}
4140-
<dd>
4141-
<ol>
4142-
<li><p>Let <var>node</var> be null.
4143-
4144-
<li><p>If the given value is not the empty string, set <var>node</var> to a new {{Text}}
4145-
<a>node</a> whose <a for=CharacterData>data</a> is the given value and
4146-
<a for=Node>node document</a> is <a>context object</a>'s <a for=Node>node document</a>.
4147-
4148-
<li><p><a for=Node>Replace all</a> with <var>node</var> within the <a>context object</a>.
4149-
</ol>
4149+
<dd><p><a>String replace all</a> with the given value within the <a>context object</a>.
41504150

41514151
<dt>{{Attr}}
41524152
<dd><p><a>Set an existing attribute value</a> with <a>context object</a> and new value.
@@ -7347,12 +7347,18 @@ if any, and its <a>contiguous exclusive <code>Text</code> nodes</a>, and <var>no
73477347
<a for=tree>next sibling</a> <a>exclusive <code>Text</code> node</a>, if any, and its
73487348
<a>contiguous exclusive <code>Text</code> nodes</a>, avoiding any duplicates.
73497349

7350-
<p>The <dfn export id=concept-child-text-content>child text content</dfn> of a <a>node</a>
7350+
<p>The <dfn export id=concept-child-text-content>child text content</dfn> of a <a for=/>node</a>
73517351
<var>node</var> is the <a for=string>concatenation</a> of the <a for=CharacterData>data</a> of all
7352-
the {{Text}} node <a>children</a> of <var>node</var>, in <a>tree order</a>.
7352+
the {{Text}} <a for=/>node</a> <a>children</a> of <var>node</var>, in <a>tree order</a>.
73537353

73547354
<p>This and <a lt="other applicable specifications">other specifications</a> may define
7355-
<dfn export id=concept-node-text-change-ext>child text content change steps</dfn> for <a for=/>nodes</a>.
7355+
<dfn export id=concept-node-text-change-ext>child text content change steps</dfn> for
7356+
<a for=/>nodes</a>.
7357+
7358+
<p>The <dfn export id=concept-descendant-text-content>descendant text content</dfn> of a
7359+
<a for=/>node</a> <var>node</var> is the <a for=string>concatenation</a> of the
7360+
<a for=CharacterData>data</a> of all the {{Text}} <a for=/>node</a> <a>descendants</a> of
7361+
<var>node</var>, in <a>tree order</a>.
73567362

73577363
<hr>
73587364

0 commit comments

Comments
 (0)