Repository navigation
fix(compiler-vapor): keep end tags inside and around form elements - #15693
Merged
edison1105 merged 1 commit intoSep 28, 2026
Merged
Conversation
`</form>` goes through the form element pointer and removes only the form element itself, so an element inside a form whose end tag is emitted has to close itself. `form` is added to ALWAYS_CLOSE_TAGS so a form off the rightmost path keeps its end tag and resets the pointer for the next form. fix vuejs#15691
|
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 ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
@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: |
Size ReportBundles
Usages
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Vapor template that puts an element inside a
<form>renders the wrong tree. For<section><form><div>x</div></form><p>y</p></section>the compiler emits<section><form><div>x</form><p>y, and the parser puts the<p>inside the form's<div>instead ofafter the form. In
<div><form>...</form></div><div><form>...</form></div>the second<form>start tag isdropped while its children stay. When a binding follows the form, the render function takes
next(form),gets
nulland mounting throwsCannot read properties of null (reading 'firstChild'). Onlyclient-created trees are affected. Hydration adopts the server DOM and parses no template string.
template()builds the DOM from an HTML string, where shipping parsers routeformthrough the formelement pointer:
</form>removes the form element alone rather than popping up to it, so a descendantwhose end tag was omitted stays open and adopts the form's next sibling; and a form closed by its parent's
end tag leaves the pointer set, which makes the parser ignore the next
<form>start tag.canOmitEndTagin
transforms/transformElement.tsaccounted for neither, so it dropped the end tag of the form's lastchild. This adds
formtoALWAYS_CLOSE_TAGSinshared/src/domTagConfig.tsso a form off the rightmostpath keeps its end tag and resets the pointer, and makes
canOmitEndTagkeep the end tag of every elementinside a form whose end tag is emitted. A form on the rightmost path still omits as before; the cost is a
few extra end tags inside forms that are not. The fix is correct under both the old parse rule and
whatwg/html#12911.
This is the mechanism of #14336, which 3d550db (#14337) fixed only for a
<button>as the form's lastchild; #15657 covers the same class for foreign content. Fix proposed by @denismrte in #15691.
fix #15691