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
type: dfn; text: prepare the script element; url: prepare-the-script-element
124
124
type: dfn; text: The text insertion mode; url: parsing-main-incdata
125
+
type: dfn; text: The rules for parsing tokens in foreign content; url: parsing-main-inforeign
125
126
type: dfn; text: reentrant invocation of the parser; url: nestedParsing
126
127
type: dfn; text: get the text steps; url: get-the-text-steps
127
128
type: dfn; text: set the inner text steps; url: set-the-inner-text-steps
@@ -1070,8 +1071,8 @@ Given a {{TrustedType}} type (|expectedType|), a [=realm/global object=] (|globa
1070
1071
1071
1072
Given an {{HTMLScriptElement}} (|script|), this algorithm performs the following steps:
1072
1073
1073
-
1. If |script|'s [=script text=] value is not equal to its [=child text content=],
1074
-
set |script|'s [=script text=] to the result of executing [$Get Trusted Type compliant string$], with the following arguments:
1074
+
1. If |script|'s [=HTMLScriptElement/script text=] value is not equal to its [=child text content=],
1075
+
set |script|'s [=HTMLScriptElement/script text=] to the result of executing [$Get Trusted Type compliant string$], with the following arguments:
1075
1076
* {{TrustedScriptURL}} as |expectedType|,
1076
1077
* |script|'s {{Document}}'s [=relevant global object=] as |global|,
1077
1078
* |script|'s [=child text content=] attribute value,
@@ -1177,14 +1178,21 @@ This document modifies {{HTMLScriptElement}}s. Each script has:
1177
1178
through a compliant sink. Equivalent to script's
1178
1179
[=child text content=]. Initially an empty string.
1179
1180
1181
+
This document also modifies {{SVGScriptElement}}s. Each script has:
1182
+
1183
+
: an associated string <dfn export for="SVGScriptElement">script text</dfn>.
1184
+
:: A string, containing the body of the script to execute that was set
1185
+
through a compliant sink. Equivalent to script's
1186
+
[=child text content=]. Initially an empty string.
1187
+
1180
1188
#### The {{HTMLScriptElement/innerText}} IDL attribute #### {#the-innerText-idl-attribute}
1181
1189
1182
1190
The {{HTMLScriptElement/innerText}} setter steps are:
1183
1191
1184
1192
1. Let |value| be the result of calling [$Get Trusted Type compliant string$] with
1185
1193
{{TrustedScript}}, [=this=]'s [=relevant global object=], the given value, `HTMLScriptElement innerText`, and
1186
1194
`script`.
1187
-
1. Set [=this=]'s [=script text=] value to |value|.
1195
+
1. Set [=this=]'s [=HTMLScriptElement/script text=] value to |value|.
1188
1196
1. Run [=set the inner text steps=] with [=this=] and |value|.
1189
1197
1190
1198
The {{HTMLScriptElement/innerText}} getter steps are:
@@ -1199,7 +1207,7 @@ empty string instead, and then do as described below:
1199
1207
1. Let |value| be the result of calling [$Get Trusted Type compliant string$] with
1200
1208
{{TrustedScript}}, [=this=]'s [=relevant global object=], the given value, `HTMLScriptElement textContent`, and
1201
1209
`script`.
1202
-
1. Set [=this=]'s [=script text=] value to |value|.
1210
+
1. Set [=this=]'s [=HTMLScriptElement/script text=] value to |value|.
1203
1211
1. Run [=set text content=] with [=this=] and |value|.
1204
1212
1205
1213
The {{HTMLScriptElement/textContent}} getter steps are:
@@ -1213,7 +1221,7 @@ Update the {{HTMLScriptElement/text}} setter steps algorithm as follows.
1213
1221
1. <ins>Let |value| be the result of calling [$Get Trusted Type compliant string$] with
1214
1222
{{TrustedScript}}, [=this=]'s [=relevant global object=], the given value, `HTMLScriptElement text`, and
1215
1223
`script`.</ins>
1216
-
1. <ins>Set [=this=]'s [=script text=] value to the given value.</ins>
1224
+
1. <ins>Set [=this=]'s [=HTMLScriptElement/script text=] value to the given value.</ins>
1217
1225
1. [=String replace all=] with the given value within [=this=].
1218
1226
1219
1227
@@ -1228,7 +1236,7 @@ The {{HTMLScriptElement/src}} setter steps are:
1228
1236
1229
1237
#### Setting slot values from parser #### {#setting-slot-values-from-parser}
1230
1238
1231
-
This document modifies the HTML parser to set the [=script text=] value when the script is created.
1239
+
This document modifies the HTML parser to set the [=HTMLScriptElement/script text=] value when the script is created.
1232
1240
1233
1241
Modify the [=The text insertion mode=] algorithm as follows:
1234
1242
@@ -1237,7 +1245,7 @@ Modify the [=The text insertion mode=] algorithm as follows:
1237
1245
<dd>
1238
1246
<p>...</p>
1239
1247
1240
-
<ins><p>Set <var>script</var>'s [=script text=] value to its [=child text content=].</p></ins>
1248
+
<ins><p>Set <var>script</var>'s [=HTMLScriptElement/script text=] value to its [=child text content=].</p></ins>
1241
1249
1242
1250
<p>If the <span>active speculative HTML parser</span> is null, then <span>prepare the script
1243
1251
element</span><var>script</var>. This might cause some script to execute, which might cause
@@ -1248,7 +1256,27 @@ Modify the [=The text insertion mode=] algorithm as follows:
1248
1256
</dd>
1249
1257
</dl>
1250
1258
1251
-
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).
1259
+
This document also modifies the HTML parser to set the [=SVGScriptElement/script text=] value when the script is created.
1260
+
1261
+
Modify the [=The rules for parsing tokens in foreign content=] as follows:
1262
+
1263
+
<dl class="switch">
1264
+
<dt id="scriptForeignEndTag">An end tag whose tag name is "script", if the <span>current
1265
+
node</span> is an <span>SVG <code>script</code></span> element</dt>
1266
+
<dd>
1267
+
<p>...</p>
1268
+
1269
+
<ins><p>Set <var>script</var>'s [=SVGScriptElement/script text=] value to its [=child text content=].</p></ins>
1270
+
1271
+
<p>If the <span>active speculative HTML parser</span> is null and the user agent supports SVG,
1272
+
then <a href="https://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process the
1273
+
SVG <code data-x="">script</code> element</a> according to the SVG rules.
1274
+
1275
+
<p>...</p>
1276
+
</dd>
1277
+
</dl>
1278
+
1279
+
Issue: The above algorithms don'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).
1252
1280
1253
1281
#### Slot value verification #### {#slot-value-verification}
1254
1282
@@ -1270,10 +1298,12 @@ The first few steps of the [=prepare the script element=] algorithm are modified
1270
1298
run when the parser tries to run it, but it is later executed after a script dynamically
1271
1299
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>
1272
1300
<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>
1273
-
<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>
1301
+
<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>
1274
1302
<li>...
1275
1303
</ol>
1276
1304
1305
+
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.
0 commit comments