You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document modifies {{HTMLScriptElement}}s. Each script has:
1181
1179
1182
-
: an associated string <dfn export for="HTMLScriptElement">script text</dfn>.
1183
-
:: A string, containing the body of the script to execute that was set
1184
-
through a compliant sink. Equivalent to script's
1185
-
[=child text content=]. Initially an empty string.
1180
+
: an associated boolean <dfn export for="HTMLScriptElement">is trusted</dfn>.
1181
+
:: A boolean indicating whether a script element is considered trustworthy for execution.
1182
+
Initially true.
1183
+
1184
+
: an associated boolean <dfn export for="HTMLScriptElement">changed by trusted sink</dfn>.
1185
+
:: A boolean indicating whether a script element has been modified by a trusted sink.
1186
+
Initially false.
1187
+
1188
+
This document also modifies {{SVGScriptElement}}s. Each script has:
1189
+
1190
+
: an associated boolean <dfn export for="SVGScriptElement">is trusted</dfn>.
1191
+
:: A boolean indicating whether a script element is considered trustworthy for execution.
1192
+
Initially true.
1186
1193
1187
1194
#### The {{HTMLScriptElement/innerText}} IDL attribute #### {#the-innerText-idl-attribute}
1188
1195
@@ -1191,7 +1198,7 @@ The {{HTMLScriptElement/innerText}} setter steps are:
1191
1198
1. Let |value| be the result of calling [$Get Trusted Type compliant string$] with
1192
1199
{{TrustedScript}}, [=this=]'s [=relevant global object=], the given value, `HTMLScriptElement innerText`, and
1193
1200
`script`.
1194
-
1. Set [=this=]'s [=script text=]value to |value|.
1201
+
1. Set [=this=]'s [=HTMLScriptElement/changed by trusted sink=] to true.
1195
1202
1. Run [=set the inner text steps=] with [=this=] and |value|.
1196
1203
1197
1204
The {{HTMLScriptElement/innerText}} getter steps are:
@@ -1206,8 +1213,8 @@ empty string instead, and then do as described below:
1206
1213
1. Let |value| be the result of calling [$Get Trusted Type compliant string$] with
1207
1214
{{TrustedScript}}, [=this=]'s [=relevant global object=], the given value, `HTMLScriptElement textContent`, and
1208
1215
`script`.
1209
-
1. Set [=this=]'s [=script text=] value to |value|.
1210
1216
1. Run [=set text content=] with [=this=] and |value|.
1217
+
1. Set [=this=]'s [=HTMLScriptElement/changed by trusted sink=] to true.
1211
1218
1212
1219
The {{HTMLScriptElement/textContent}} getter steps are:
1213
1220
@@ -1220,8 +1227,8 @@ Update the {{HTMLScriptElement/text}} setter steps algorithm as follows.
1220
1227
1. <ins>Let |value| be the result of calling [$Get Trusted Type compliant string$] with
1221
1228
{{TrustedScript}}, [=this=]'s [=relevant global object=], the given value, `HTMLScriptElement text`, and
1222
1229
`script`.</ins>
1223
-
1. <ins>Set [=this=]'s [=script text=] value to the given value.</ins>
1224
1230
1. [=String replace all=] with the given value within [=this=].
1231
+
1. Set [=this=]'s [=HTMLScriptElement/changed by trusted sink=] to true.
1225
1232
1226
1233
1227
1234
#### The {{HTMLScriptElement/src}} IDL attribute #### {#the-src-idl-attribute}
@@ -1233,29 +1240,21 @@ The {{HTMLScriptElement/src}} setter steps are:
1233
1240
`script`.</ins>
1234
1241
1. <ins>Set [=this=]'s [=src=] content attribute to |value|.</ins>
1235
1242
1236
-
#### Setting slot values from parser #### {#setting-slot-values-from-parser}
1243
+
#### Script children changed steps #### {#script-children-changed-steps}
1237
1244
1238
-
This document modifies the HTML parser to set the [=script text=]value when the script is created.
1245
+
This document modifies the [=children changed steps=]for {{HTMLScriptElement}} as follows:
1239
1246
1240
-
Modify the [=The text insertion mode=] algorithm as follows:
1247
+
1. If <var ignore=''>parserChange</var> is false, set [=this=]'s [=HTMLScriptElement/is trusted=] to false.
1241
1248
1242
-
<dl class="switch">
1243
-
<dt id="scriptEndTag">An end tag whose tag name is "script"</dt>
1244
-
<dd>
1245
-
<p>...</p>
1249
+
1. If [=this=]'s [=HTMLScriptElement/changed by trusted sink=] is true, set [=this=]'s [=HTMLScriptElement/is trusted=] to false.
1246
1250
1247
-
<ins><p>Set <var>script</var>'s [=script text=] value to its [=child text content=].</p></ins>
1251
+
1. Set [=this=]'s [=HTMLScriptElement/changed by trusted sink=] to false.
1248
1252
1249
-
<p>If the <span>active speculative HTML parser</span> is null, then <span>prepare the script
1250
-
element</span><var>script</var>. This might cause some script to execute, which might cause
1251
-
<span data-x="dom-document-write">new characters to be inserted into the tokenizer</span>, and
1252
-
might cause the tokenizer to output more tokens, resulting in a [=reentrant invocation of the parser=].</p>
1253
+
Issue: Need to double check how [part of script element's spec](https://html.spec.whatwg.org/#prepare-the-script-element:~:text=When%20a%20script%20element%20el%20that%20is%20not%20parser%2Dinserted%20experiences) fits into this. These steps need to happen before prepare the script is called.
1253
1254
1254
-
<p>...</p>
1255
-
</dd>
1256
-
</dl>
1255
+
This document modifies the [=children changed steps=] for {{SVGScriptElement}} as follows:
1257
1256
1258
-
Issue: The above algorithm doesn't account for the case when the script element's content is changed mid-parse. Implementors should ensure they protect against this case. See [https://github.com/w3c/trusted-types/issues/507](https://github.com/w3c/trusted-types/issues/507).
1257
+
1. If <var ignore=''>parserChange</var>is false, set [=this=]'s [=SVGScriptElement/is trusted=] to false.
1259
1258
1260
1259
#### Slot value verification #### {#slot-value-verification}
1261
1260
@@ -1277,10 +1276,12 @@ The first few steps of the [=prepare the script element=] algorithm are modified
1277
1276
run when the parser tries to run it, but it is later executed after a script dynamically
1278
1277
updates it, it will execute in an async fashion even if the <code id=script-processing-model:attr-script-async-5><a href=https://html.spec.whatwg.org/#attr-script-async>async</a></code> attribute isn't set.</p>
1279
1278
<li><ins><p>Execute the [$Prepare the script text$] algorithm on <var>el</var>. If that algorithm threw an error, then return.</p></ins></li>
1280
-
<li><p>Let <var ignore="">source text</var> be <var>el</var>'s <del><a id=script-processing-model:child-text-content href=https://dom.spec.whatwg.org/#concept-child-text-content data-x-internal=child-text-content>child text content</a>.</del><ins>[=script text=] value.</ins>
1279
+
<li><p>Let <var ignore="">source text</var> be <var>el</var>'s <del><a id=script-processing-model:child-text-content href=https://dom.spec.whatwg.org/#concept-child-text-content data-x-internal=child-text-content>child text content</a>.</del><ins>[=HTMLScriptElement/script text=] value.</ins>
1281
1280
<li>...
1282
1281
</ol>
1283
1282
1283
+
Issue: There's no proper definition for the processing of SVG script elements. However, you should apply a similar change to the processing of {{SVGScriptElement}}s.
1284
+
1284
1285
## Integration with DOM ## {#integration-with-dom}
1285
1286
1286
1287
Note: See [https://github.com/whatwg/dom/pull/1258](https://github.com/whatwg/dom/pull/1258) and [https://github.com/whatwg/dom/pull/1268](https://github.com/whatwg/dom/pull/1268) which upstream this integration.
0 commit comments