-
-
Notifications
You must be signed in to change notification settings - Fork 9k
refactor(compile-vapor): skip unnecessary closing tags in templates #13667
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
base: minor
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
|
Thanks for your PR. Could you please add some tests in dom/template.spec.ts? |
|
I've added tests in fb678dd. 👍🏻 |
fb678dd to
369b70b
Compare
|
Rebased the changes to solve conflicts 😄 |
This PR improves the compiled code for Vapor components, by omitting unnecessary HTML close tags resulting in a smaller output. Resolves a TODO specified in code comments.
Closing tags are skipped when the element is the last child of its parent. Even when the parent isn't the last element of the grandparent except for formatting elements (as defined by the HTML spec) since they cause issues with reconstruction, and when the parent has the same tag (since the parent's closing tag would actually close the child).
If the above description isn't clear enough, perhaps this table (+ the tests) will shed some light on the compiler's behavior.
<div><span/></div><div><span><div><span/><span/></div><div><span></span><span><div><p><span/></p><span/></div><div><p><span></p><span><div><p><b/></p><span/></div><div><p><b></b></p><span><div><div><span/></div><div/></div><div><div><span></div><div><div><div><div/></div><div/></div><div><div><div></div></div><div>