Skip to content

Commit fbb3a86

Browse files
lukewarlowannevk
authored andcommitted
Trusted Types integration for "converting nodes into a node"
Covered by existing tests. Co-authored-by: Anne van Kesteren <[email protected]>
1 parent a36fb1b commit fbb3a86

File tree

1 file changed

+49
-21
lines changed

1 file changed

+49
-21
lines changed

dom.bs

+49-21
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ spec:html; type:element
5252
<p>This specification depends on the Infra Standard. [[!INFRA]]
5353

5454
<p>Some of the terms used in this specification are defined in <cite>Encoding</cite>,
55-
<cite>Selectors</cite>, <cite>Web IDL</cite>, <cite>XML</cite>, and <cite>Namespaces in XML</cite>.
55+
<cite>Selectors</cite>, <cite>Trusted Types</cite>, <cite>Web IDL</cite>, <cite>XML</cite>, and
56+
<cite>Namespaces in XML</cite>.
5657
[[!ENCODING]]
5758
[[!SELECTORS4]]
59+
[[!TRUSTED-TYPES]]
5860
[[!WEBIDL]]
5961
[[!XML]]
6062
[[!XML-NAMES]]
@@ -3033,8 +3035,9 @@ standards that want to define APIs shared between <a for=/>documents</a> and
30333035

30343036
<h4 id=interface-parentnode>Mixin {{ParentNode}}</h4>
30353037

3036-
<p>To <dfn export lt="converting nodes into a node">convert nodes into a node</dfn>, given
3037-
<var>nodes</var> and <var>document</var>, run these steps:
3038+
<p>To <dfn export lt="converting nodes into a node">convert nodes into a node</dfn>, given a
3039+
<a for=/>node</a> <var>parent</var>, <a for=/>list</a> of <a for=/>nodes</a> <var>nodes</var>, and
3040+
<a for=/>document</a> <var>document</var>:
30383041

30393042
<ol>
30403043
<li><p>Let <var>node</var> be null.
@@ -3043,12 +3046,37 @@ standards that want to define APIs shared between <a for=/>documents</a> and
30433046
<a for=CharacterData>data</a> is the string and <a for=Node>node document</a> is
30443047
<var>document</var>.
30453048

3046-
<li><p>If <var>nodes</var> contains one <a for=/>node</a>, then set <var>node</var> to
3047-
<var>nodes</var>[0].
3049+
<li><p>Let <var>isScriptElement</var> be true if <var>parent</var> is an {{HTMLScriptElement}}
3050+
<a for=/>node</a>; otherwise false.
3051+
3052+
<li><p>Let <var>newNodes</var> be « ».
3053+
3054+
<li>
3055+
<p><a for=list>For each</a> <var>value</var> of <var>nodes</var>:
3056+
3057+
<ol>
3058+
<li><p>Let <var>newValue</var> be <var>value</var>.
3059+
3060+
<li><p>If <var>value</var> is a {{Text}} <a for=/>node</a> and <var>isScriptElement</var> is
3061+
true, then set <var>newValue</var> to a new {{Text}} <a for=/>node</a> whose
3062+
<a for=Node>node document</a> is <var>document</var> and <a for=CharacterData>data</a> is the
3063+
result of calling <a abstract-op>Get Trusted Type compliant string</a>, with {{TrustedScript}},
3064+
<var>document</var>'s <a>relevant global object</a>, <var>value</var>'s
3065+
<a for=CharacterData>data</a>, "<code>HTMLScriptElement text</code>", and "<code>script</code>".
3066+
3067+
<li><p>If <var>value</var> is a {{TrustedScript}}, then set <var>newValue</var> to a new {{Text}}
3068+
<a for=/>node</a> whose <a for=CharacterData>data</a> is <var>value</var>'s
3069+
<a for=TrustedScript>data</a> and <a for=Node>node document</a> is <var>document</var>.
3070+
3071+
<li><p><a for=list>Append</a> <var>newValue</var> to <var>newNodes</var>.
3072+
</ol>
3073+
3074+
<li><p>If <var>newNodes</var> contains one <a for=/>node</a>, then set <var>node</var> to
3075+
<var>newNodes</var>[0].
30483076

30493077
<li><p>Otherwise, set <var>node</var> to a new {{DocumentFragment}} <a for=/>node</a> whose
30503078
<a for=Node>node document</a> is <var>document</var>, and then <a>append</a> each <a for=/>node</a>
3051-
in <var>nodes</var>, if any, to it.
3079+
in <var>newNodes</var>, if any, to it.
30523080

30533081
<li><p>Return <var>node</var>.
30543082
</ol>
@@ -3060,9 +3088,9 @@ interface mixin ParentNode {
30603088
readonly attribute Element? lastElementChild;
30613089
readonly attribute unsigned long childElementCount;
30623090

3063-
[CEReactions, Unscopable] undefined prepend((Node or DOMString)... nodes);
3064-
[CEReactions, Unscopable] undefined append((Node or DOMString)... nodes);
3065-
[CEReactions, Unscopable] undefined replaceChildren((Node or DOMString)... nodes);
3091+
[CEReactions, Unscopable] undefined prepend((Node or TrustedScript or DOMString)... nodes);
3092+
[CEReactions, Unscopable] undefined append((Node or TrustedScript or DOMString)... nodes);
3093+
[CEReactions, Unscopable] undefined replaceChildren((Node or TrustedScript or DOMString)... nodes);
30663094

30673095
Element? querySelector(DOMString selectors);
30683096
[NewObject] NodeList querySelectorAll(DOMString selectors);
@@ -3136,8 +3164,8 @@ the number of <a for=tree>children</a> of <a>this</a> that are <a for=/>elements
31363164
<p>The <dfn method for=ParentNode><code>prepend(<var>nodes</var>)</code></dfn> method steps are:
31373165

31383166
<ol>
3139-
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given
3140-
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
3167+
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given <a>this</a>,
3168+
<var>nodes</var>, and <a>this</a>'s <a for=Node>node document</a>.
31413169

31423170
<li><p><a>Pre-insert</a> <var>node</var> into <a>this</a> before <a>this</a>'s
31433171
<a for=tree>first child</a>.
@@ -3146,8 +3174,8 @@ the number of <a for=tree>children</a> of <a>this</a> that are <a for=/>elements
31463174
<p>The <dfn method for=ParentNode><code>append(<var>nodes</var>)</code></dfn> method steps are:
31473175

31483176
<ol>
3149-
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given
3150-
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
3177+
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given <a>this</a>,
3178+
<var>nodes</var>, and <a>this</a>'s <a for=Node>node document</a>.
31513179

31523180
<li><p><a>Append</a> <var>node</var> to <a>this</a>.
31533181
</ol>
@@ -3156,8 +3184,8 @@ the number of <a for=tree>children</a> of <a>this</a> that are <a for=/>elements
31563184
are:
31573185

31583186
<ol>
3159-
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given
3160-
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
3187+
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given <a>this</a>,
3188+
<var>nodes</var>, and <a>this</a>'s <a for=Node>node document</a>.
31613189

31623190
<li><p><a>Ensure pre-insertion validity</a> of <var>node</var> into <a>this</a> before
31633191
null.
@@ -3212,9 +3240,9 @@ steps are to return the first <a>following</a> <a for=tree>sibling</a> that is a
32123240

32133241
<pre class=idl>
32143242
interface mixin ChildNode {
3215-
[CEReactions, Unscopable] undefined before((Node or DOMString)... nodes);
3216-
[CEReactions, Unscopable] undefined after((Node or DOMString)... nodes);
3217-
[CEReactions, Unscopable] undefined replaceWith((Node or DOMString)... nodes);
3243+
[CEReactions, Unscopable] undefined before((Node or TrustedScript or DOMString)... nodes);
3244+
[CEReactions, Unscopable] undefined after((Node or TrustedScript or DOMString)... nodes);
3245+
[CEReactions, Unscopable] undefined replaceWith((Node or TrustedScript or DOMString)... nodes);
32183246
[CEReactions, Unscopable] undefined remove();
32193247
};
32203248
DocumentType includes ChildNode;
@@ -3262,7 +3290,7 @@ CharacterData includes ChildNode;
32623290
<a for=tree>sibling</a> not in <var>nodes</var>; otherwise null.
32633291

32643292
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a>, given
3265-
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
3293+
<var>parent</var>, <var>nodes</var>, and <a>this</a>'s <a for=Node>node document</a>.
32663294

32673295
<li><p>If <var>viablePreviousSibling</var> is null, then set it to <var>parent</var>'s
32683296
<a for=tree>first child</a>; otherwise to <var>viablePreviousSibling</var>'s
@@ -3283,7 +3311,7 @@ CharacterData includes ChildNode;
32833311
<a for=tree>sibling</a> not in <var>nodes</var>; otherwise null.
32843312

32853313
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a>, given
3286-
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
3314+
<var>parent</var>, <var>nodes</var>, and <a>this</a>'s <a for=Node>node document</a>.
32873315

32883316
<li><p><a>Pre-insert</a> <var>node</var> into <var>parent</var> before
32893317
<var>viableNextSibling</var>.
@@ -3300,7 +3328,7 @@ CharacterData includes ChildNode;
33003328
<a for=tree>sibling</a> not in <var>nodes</var>; otherwise null.
33013329

33023330
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a>, given
3303-
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
3331+
<var>parent</var>, <var>nodes</var>, and <a>this</a>'s <a for=Node>node document</a>.
33043332

33053333
<li>
33063334
<p>If <a>this</a>'s <a for=tree>parent</a> is <var>parent</var>, <a>replace</a> <a>this</a> with

0 commit comments

Comments
 (0)