Skip to content

Commit 4de6eb9

Browse files
committed
Integration with trusted types inside of node conversion
1 parent 73995b1 commit 4de6eb9

File tree

1 file changed

+56
-17
lines changed

1 file changed

+56
-17
lines changed

dom.bs

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,15 +3031,54 @@ standards that want to define APIs shared between <a for=/>documents</a> and
30313031
<h4 id=interface-parentnode>Mixin {{ParentNode}}</h4>
30323032

30333033
<p>To <dfn export lt="converting nodes into a node">convert nodes into a node</dfn>, given
3034-
<var>nodes</var> and <var>document</var>, run these steps:
3034+
<var>parent</var>, <var>nodes</var> and <var>document</var>, run these steps:
30353035

30363036
<ol>
3037+
<li><p>Let <var>isScriptElement</var> be <var>parent</var> is a {{HTMLScriptElement}}.
3038+
<li><p>For each <var>value</var> in <var>nodes</var>:
3039+
<ol>
3040+
<li>If <var>value</var> is a <a for=/>node</a>, then:
3041+
<ol>
3042+
<li>If <var>isScriptElement</var> is false, skip to the next <var>value</var>.
3043+
<li>If <var>value</var>'s {{nodeType}} is not {{TEXT_NODE}}, skip to the next <var>value</var>.
3044+
<li>Let <var>text</var> be the result of executing the [$Get Trusted Type compliant string$] algorithm, with the following arguments:
3045+
* {{TrustedScript}} as <var>expectedType</var>,
3046+
* <var>document</var>'s [=relevant global object=] as <var>global</var>,
3047+
* <var>value</var>'s <a for=CharacterData>data</a> as <var>input</var>,
3048+
* `HTMLScriptElement text` as <var>sink</var>,
3049+
* `script` as <var>sinkGroup</var>.
3050+
3051+
<p>If the algorithm threw an error, rethrow the error.
3052+
<li>Set <var>value</var>'s <a for=CharacterData>data</a> to <var>text</var>.
3053+
</ol>
3054+
<li>If <var>value</var> is a string, then:
3055+
<ol>
3056+
<li>Let <var>text</var> be <var>value</var>.
3057+
<li>If <var>isScriptElement</var> is true:
3058+
<ol>
3059+
<li>Let <var>text</var> be the result of executing the [$Get Trusted Type compliant string$] algorithm, with the following arguments:
3060+
* {{TrustedScript}} as <var>expectedType</var>,
3061+
* <var>document</var>'s [=relevant global object=] as <var>global</var>,
3062+
* <var>value</var> as <var>input</var>,
3063+
* `HTMLScriptElement text` as <var>sink</var>,
3064+
* `script` as <var>sinkGroup</var>.
3065+
3066+
If the algorithm threw an error, rethrow the error.
3067+
<li>Let <var>newValue</var> be a new {{Text}} <a for=/>node</a> whose
3068+
<a for=CharacterData>data</a> is <var>text</var> and <a for=Node>node document</a> is <var>document</var>.
3069+
<li>Replace <var>value</var> with <var>newValue</var>.
3070+
</ol>
3071+
</ol>
3072+
<li>If <var>value</var> is a {{TrustedScript}}, then:
3073+
<ol>
3074+
<li>Let <var>text</var> be <var>value</var>'s Data internal slot value.
3075+
<li>Let <var>newValue</var> be a new {{Text}} <a for=/>node</a> whose
3076+
<a for=CharacterData>data</a> is <var>text</var> and <a for=Node>node document</a> is <var>document</var>.
3077+
<li>Replace <var>value</var> with <var>newValue</var>.
3078+
</ol>
3079+
</ol>
30373080
<li><p>Let <var>node</var> be null.
30383081

3039-
<li><p>Replace each string in <var>nodes</var> with a new {{Text}} <a for=/>node</a> whose
3040-
<a for=CharacterData>data</a> is the string and <a for=Node>node document</a> is
3041-
<var>document</var>.
3042-
30433082
<li><p>If <var>nodes</var> contains one <a for=/>node</a>, then set <var>node</var> to
30443083
<var>nodes</var>[0].
30453084

@@ -3057,9 +3096,9 @@ interface mixin ParentNode {
30573096
readonly attribute Element? lastElementChild;
30583097
readonly attribute unsigned long childElementCount;
30593098

3060-
[CEReactions, Unscopable] undefined prepend((Node or DOMString)... nodes);
3061-
[CEReactions, Unscopable] undefined append((Node or DOMString)... nodes);
3062-
[CEReactions, Unscopable] undefined replaceChildren((Node or DOMString)... nodes);
3099+
[CEReactions, Unscopable] undefined prepend((Node or DOMString or TrustedScript)... nodes);
3100+
[CEReactions, Unscopable] undefined append((Node or DOMString or TrustedScript)... nodes);
3101+
[CEReactions, Unscopable] undefined replaceChildren((Node or DOMString or TrustedScript)... nodes);
30633102

30643103
Element? querySelector(DOMString selectors);
30653104
[NewObject] NodeList querySelectorAll(DOMString selectors);
@@ -3133,7 +3172,7 @@ the number of <a for=tree>children</a> of <a>this</a> that are <a for=/>elements
31333172
<p>The <dfn method for=ParentNode><code>prepend(<var>nodes</var>)</code></dfn> method steps are:
31343173

31353174
<ol>
3136-
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given
3175+
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given <a>this</a>,
31373176
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
31383177

31393178
<li><p><a>Pre-insert</a> <var>node</var> into <a>this</a> before <a>this</a>'s
@@ -3143,7 +3182,7 @@ the number of <a for=tree>children</a> of <a>this</a> that are <a for=/>elements
31433182
<p>The <dfn method for=ParentNode><code>append(<var>nodes</var>)</code></dfn> method steps are:
31443183

31453184
<ol>
3146-
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given
3185+
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given <a>this</a>,
31473186
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
31483187

31493188
<li><p><a>Append</a> <var>node</var> to <a>this</a>.
@@ -3153,7 +3192,7 @@ the number of <a for=tree>children</a> of <a>this</a> that are <a for=/>elements
31533192
are:
31543193

31553194
<ol>
3156-
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given
3195+
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a> given <a>this</a>,
31573196
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
31583197

31593198
<li><p><a>Ensure pre-insertion validity</a> of <var>node</var> into <a>this</a> before
@@ -3209,9 +3248,9 @@ steps are to return the first <a>following</a> <a for=tree>sibling</a> that is a
32093248

32103249
<pre class=idl>
32113250
interface mixin ChildNode {
3212-
[CEReactions, Unscopable] undefined before((Node or DOMString)... nodes);
3213-
[CEReactions, Unscopable] undefined after((Node or DOMString)... nodes);
3214-
[CEReactions, Unscopable] undefined replaceWith((Node or DOMString)... nodes);
3251+
[CEReactions, Unscopable] undefined before((Node or DOMString or TrustedScript)... nodes);
3252+
[CEReactions, Unscopable] undefined after((Node or DOMString or TrustedScript)... nodes);
3253+
[CEReactions, Unscopable] undefined replaceWith((Node or DOMString or TrustedScript)... nodes);
32153254
[CEReactions, Unscopable] undefined remove();
32163255
};
32173256
DocumentType includes ChildNode;
@@ -3259,7 +3298,7 @@ CharacterData includes ChildNode;
32593298
<a for=tree>sibling</a> not in <var>nodes</var>; otherwise null.
32603299

32613300
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a>, given
3262-
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
3301+
<var>parent</var>, <var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
32633302

32643303
<li><p>If <var>viablePreviousSibling</var> is null, then set it to <var>parent</var>'s
32653304
<a for=tree>first child</a>; otherwise to <var>viablePreviousSibling</var>'s
@@ -3280,7 +3319,7 @@ CharacterData includes ChildNode;
32803319
<a for=tree>sibling</a> not in <var>nodes</var>; otherwise null.
32813320

32823321
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a>, given
3283-
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
3322+
<var>parent</var>, <var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
32843323

32853324
<li><p><a>Pre-insert</a> <var>node</var> into <var>parent</var> before
32863325
<var>viableNextSibling</var>.
@@ -3297,7 +3336,7 @@ CharacterData includes ChildNode;
32973336
<a for=tree>sibling</a> not in <var>nodes</var>; otherwise null.
32983337

32993338
<li><p>Let <var>node</var> be the result of <a>converting nodes into a node</a>, given
3300-
<var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
3339+
<var>parent</var>, <var>nodes</var> and <a>this</a>'s <a for=Node>node document</a>.
33013340

33023341
<li>
33033342
<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)