-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: migrate from vue/compiler-dom to parse5 #9678
Conversation
Vite Ecosystem CI is green for this PR (except for known glitches being solved on some projects): https://github.com/vitejs/vite-ecosystem-ci/actions/runs/2860308763 About issuing a warning for duplicate attributes, @surma mentioned that it could be noisy. I agree that without a way to turn these off, it may be bothersome if you can't fix your tooling. |
I think we can skip all of them if we want to be lenient with the html being passed. Otherwise we should report all the warnings instead as it could be confusing if we only report some of it. |
Co-authored-by: Shinigami <chrissi92@hotmail.de>
Co-authored-by: 翠 / green <green@sapphi.red>
Co-authored-by: 翠 / green <green@sapphi.red>
Thanks a lot for the review @sapphi-red! I now recall why I didn't add all these guards. If you check in the https://astexplorer.net/#/1CHlCXc4n4, you'll see that when there are duplicated attrs, parse5 will already only have the first one in the attr array. Maybe I'm not looking at this correctly? Did you hit an issue with duplicates? |
Oh, I wasn't aware of that. Sorry. I should have checked this on astexplorer. |
Description
Fixes #5966
Fixes #5603
Vite has been using vue/compiler-dom to process HTML (for example to process inlined URLs). There are a few issues that are out of the scope of vue/compiler-dom, and although we could extend it, we discussed with the Team that migrating to a standard compliant HTML parser is better for the future.
This PR migrates to parse5, that is battle tested library used by many other projects like jsdom, Angular, and Lit.
I decided to keep the current approach of parsing and then use MagicString to do the changes. One difference is that the code locations for attrs are in the main
node
instead of in the attr token itself, and the info for attrs is the whole attr (foo="value"
) instead of the value as we had with compiler/dom. The rest is basically the same.Remaining tasks:
For the future:
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).