-
Notifications
You must be signed in to change notification settings - Fork 2
Labels
Description
Bug Description
Currently, in JSAR Runtime, the <script>
element does not support the .text
property to retrieve its content. For example, with the following HTML snippet:
<script id="normalScript" type="text/javascript">
const a = 1;
</script>
Attempting to get the script content using JavaScript:
const normalScript = document.getElementById("normalScript").text;
console.log(normalScript); // Expected: "\n const a = 1;\n"
The .text
property should return the textual content inside the <script>
tag, as defined in the HTML Standard. This is supported in major browsers (Chromium, Gecko, WebKit).
Expected Behavior
element.text
returns the content inside the<script>
tag as a string.
Actual Behavior
element.text
isundefined
or not implemented.
Reference
- HTML Standard: dom-script-text
- Chromium implementation: HTMLScriptElement::text
- Gecko implementation: nsIScriptElement::GetScriptText
Suggested Fix
Implement the .text
property on HTMLScriptElement
so that it returns the content of the script element.
Example
<script id="normalScript" type="text/javascript">
const a = 1;
</script>
<script>
const normalScript = document.getElementById("normalScript").text;
console.log(normalScript); // Should log: "\n const a = 1;\n"
</script>
Copilot