Skip to content

Parser will extract script tags in script tags and bork the parent script #92

@tbeseda

Description

@tbeseda

Sounds wild, I know. And it's a bit of an edge case.
But if you have a script tag in an element definition, and then in that script tag you have a string that contains an open or close "<script>", the parser gets eager to start extracting scripts.

Here's a sample <my-element> that will blow up in the browser -- server render works, or at least doesn't throw

export default function ({ html }) {
  return html`
    <h1 class="text4 font-mono">my-element</h1>

    <script>
      console.log('start.')

      // this string will trip up the parser
      const someHTML2 = '<script>window.$$ = "$$";</script>'

      console.log('done.')
    </script>
  `
}

and here's a screenshot of what is rendered

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions