shelving comments and patch them at the end if needed #452
Replies: 2 comments 2 replies
-
I can see that a component with one root tag + one or more comments becoming a fragment is confusing. However, I don't see how silently ignoring comments in certain situations (even if I think a better solution is:
I don't know if adding a comment is an idiom for forcing a template to be compiled as a fragment (for whatever reason), but changing it could be a breaking change. |
Beta Was this translation helpful? Give feedback.
-
Ran into this recently and it was VERY confusing and took a long time to figure out. Please let's fix this! Also see a related idea for being more explicit about preserving comments here - #469 |
Beta Was this translation helpful? Give feedback.
-
fix(compiler-core): KeepAlive should ignore comments core#6026 HTML comment breaks automatic attribute inheritance core#5203 Root comment breaking the
<Transition>
without any warning core#6080 Attribute inheritance inconsistent across production and development core#5546 fix(compiler-core): fix patchFlag wrong on v-if in some cases core#5832Summary
We should remove comments node in ast or transform, record them on render vnode or instance to add them in patch if needed.
Motivation
Comments should not affect PatchFlag and fall-through attribute inheritance in theory, it caused a lot of problems. and it will have more problems in app.config.compilerOptions.comments, dev_root_fragment, keep-alive, transition...
Even as long as we add a function, we must consider these.
Comments do not need to participate in diff or props update In fact,we can just patch them at the end if needed. This will solve the problem once and for all.
Detailed design
As said above
Remove comments node in ast or transform, record them on render vnode or instance to add them in patch if needed
Drawbacks
There may be involve multiple parts
Adoption strategy
It is not a breaking change.
Beta Was this translation helpful? Give feedback.
All reactions