-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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. 👍🏻 |
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>