From a1862e540904d7015747f99bbf622e459bd9b7aa Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Wed, 12 Jun 2024 16:41:17 +0200 Subject: [PATCH] Update HTML Parser steps for script element to set "script text" (#499) --- spec/index.bs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/index.bs b/spec/index.bs index 56b1a2a..91962fb 100644 --- a/spec/index.bs +++ b/spec/index.bs @@ -121,6 +121,8 @@ spec:ECMA-262; urlPrefix: https://tc39.github.io/ecma262/ type:dfn; text:current realm record; url: current-realm spec: HTML; urlPrefix: https://html.spec.whatwg.org/ type: dfn; text: prepare the script element; url: prepare-the-script-element + type: dfn; text: The text insertion mode; url: parsing-main-incdata + type: dfn; text: reentrant invocation of the parser; url: nestedParsing type: dfn; text: get the text steps; url: get-the-text-steps type: dfn; text: set the inner text steps; url: set-the-inner-text-steps type: dfn; text: src; url: attr-script-src @@ -1224,6 +1226,30 @@ The {{HTMLScriptElement/src}} setter steps are: `script`. 1. Set [=this=]'s [=src=] content attribute to |value|. +#### Setting slot values from parser #### {#setting-slot-values-from-parser} + +This document modifies the HTML parser to set the [=script text=] value when the script is created. + +Modify the [=The text insertion mode=] algorithm as follows: + +
+
An end tag whose tag name is "script"
+
+

...

+ +

Set script's [=script text=] value to its [=child text content=].

+ +

If the active speculative HTML parser is null, then prepare the script + element script. This might cause some script to execute, which might cause + new characters to be inserted into the tokenizer, and + might cause the tokenizer to output more tokens, resulting in a [=reentrant invocation of the parser=].

+ +

...

+
+
+ +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). + #### Slot value verification #### {#slot-value-verification} The first few steps of the [=prepare the script element=] algorithm are modified as follows: