Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

"type" attribute of "script" tag being ignored #223

Open
1 task
MatthewPinheiro opened this issue Dec 26, 2018 · 2 comments
Open
1 task

"type" attribute of "script" tag being ignored #223

MatthewPinheiro opened this issue Dec 26, 2018 · 2 comments

Comments

@MatthewPinheiro
Copy link

MatthewPinheiro commented Dec 26, 2018

Prerequisites

Description

It seems the type attribute of the script tag isn't being properly checked in the latest version of Atom, resulting in the body of all script tags, regardless of type, being syntactically highlighted as JavaScript.

Steps to Reproduce

  1. Open new file
  2. Paste the following:
<script type="text/html">
    <p>This is highlighted as having errors</p>
    console.log('This is highlighted as being JS');
</script>
  1. Switch language to HTML

Expected behavior: The body of the script tag should be highlighted as HTML, i.e. white carets with red p's on the <p>...</p> tag and all white on the console.log(...); line.

Actual behavior: The body of the script tag is highlighted as JavaScript, with teal carets on the aforementioned tag carets and proper JS highlighting on the console.log(...) line.

Edit by @rsese to add more observations from #223 (comment)

Looks like if that snippet is put in some minimal HTML e.g.:

<!DOCTYPE html>
<html>
<body>
  <script type="text/html">
    <p>This is highlighted as having errors</p>
    console.log('This is highlighted as being JS');
</script>
</body>
</html>

Then I can reproduce initially, but after saving as a .html file and reopening, it works ok. If the code snippet is in a .html file on its own, then I see the issue there as well.

Doesn't reproduce with Tree-sitter disabled though.

Reproduces how often: Always

Versions

Atom: 1.33.1
APM: 2.1.2

OS: Windows 10 Pro v1803

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

@rsese
Copy link

rsese commented Dec 27, 2018

Thanks for the report - reproduced on 1.33.1 on macOS 10.12.6. Looks like if that snippet is put in some minimal HTML e.g.:

<!DOCTYPE html>
<html>
<body>
  <script type="text/html">
    <p>This is highlighted as having errors</p>
    console.log('This is highlighted as being JS');
</script>
</body>
</html>

Then I can reproduce initially, but after saving as a .html file and reopening, it works ok. If the code snippet is in a .html file on its own, then I see the issue there as well.

Doesn't reproduce with Tree-sitter disabled though.

@MatthewPinheiro
Copy link
Author

An update on this:
In my case, the primary cause of the issue was putting an HTML comment spanning multiple lines at the top of the file, e.g.

<!-- Hello 
World! -->
<html>
    <body>
        <script type="text/html>
            <p>Not Considered HTML</p>
        </script>
    </body>
</html>

The workaround to this was, going off the reply from @rsese , simply putting <!DOCTYPE html> at the top of the file before the comment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants