Skip to content

HTML Parser fails if you have the same attribute twice #5966

Closed
@surma

Description

@surma

Describe the bug

It seems that if you have the same attribute twice, the HTML parser to fail. (Tested it with class=, data-a= and x=. It fails for all of them.)

Reproduction

(Repro on Stackblitz.)

<!DOCTYPE html>
<div class="a" class="b"></div>

Output:

[vite] Internal server error: Unable to parse {"file":"/index.html","line":2,"column":16}
1  |  <!DOCTYPE html>
2  |  <div class="a" class="b"></div>
   |                 ^
3  |  
      at traverseHtml (/home/projects/vitejs-vite-wv2wbb/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:21240:15)
      at async devHtmlHook (/home/projects/vitejs-vite-wv2wbb/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:57001:5)
      at async applyHtmlTransforms (/home/projects/vitejs-vite-wv2wbb/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:21550:21)
      at async viteIndexHtmlMiddleware (/home/projects/vitejs-vite-wv2wbb/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:57065:28)

System Info

Stackblitz.

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: upstreamBug in a dependency of Vitefeat: htmlp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions