Skip to content

<script> element does not support .text property to get content #389

@EndlessJour9527

Description

@EndlessJour9527

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 is undefined or not implemented.

Reference

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>

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions