Skip to content

HTML Parser not not support quotes in interpolated attributes #5815

@ntotten

Description

@ntotten

In certain situations with template interpolation, quotes inside an HTML attribute could be valid HTML. The current HTML parser throws an exception when an interpolation attribute contains a quote.

Prettier pr-5800
Playground link

--parser lwc

Input:

<div data-for={value['foo']} data-for={value["foo"]}></div>

Output:

SyntaxError: Unexpected closing tag "div". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (1:54)
> 1 | <div data-for={value['foo']} data-for={value["foo"]}></div>
    |                                                      ^

Expected behavior:
The HTML parser should parse these values correctly so they can be used in the interpolation value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:htmlIssues affecting HTML (and SVG but not JSX)scope:dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependency

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions