Skip to content

Parsing error: Unterminated string constant when string includes "<body> #141

@domenic

Description

@domenic

Description

When linting the following document:

<!DOCTYPE html>
<meta charset="utf-8">
<title>innerHTML to empty string</title>
<link rel="help" href="https://w3c.github.io/DOM-Parsing/#dom-element-innerhtml">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
  "use strict";

  test(() => {
    const doc = document.createElement("html");
    doc.innerHTML = "<head><title>foo</title></head><body>";

    doc.innerHTML = "";

    assert_true(doc.getElementsByTagName("body")[0] instanceof HTMLBodyElement);

  }, "Setting innerHTML to empty string");
</script>

I get

  13:21  error  Parsing error: Unterminated string constant

This goes away if I modify line 13 from

    doc.innerHTML = "<head><title>foo</title></head><body>";

to

    doc.innerHTML = "<head><title>foo</title></head>";

Setup configuration

Aditional context

This is occuring trying to upgrade jsdom from its current version as of today to the latest versions of ESLint and eslint-plugin-html.

Activity

BenoitZugmeyer

BenoitZugmeyer commented on Mar 7, 2021

@BenoitZugmeyer
Owner

Thank you for the report! This looks like an issue with htmlparser2, so I reported the issue there.

added a commit that references this issue on Mar 8, 2021
bdc76d9
BenoitZugmeyer

BenoitZugmeyer commented on Mar 8, 2021

@BenoitZugmeyer
Owner

I upgraded htmlparser2, it should be fine now! Let me know how it works for you.

8 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @BenoitZugmeyer@domenic

      Issue actions

        Parsing error: Unterminated string constant when string includes "<body> · Issue #141 · BenoitZugmeyer/eslint-plugin-html