VIewTransitions break on presence of <input name="action"> #10849
Labels
- P3: minor bug
An edge case that only affects very specific usage (priority)
feat: view transitions
Related to the View Transitions feature (scope)
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using ViewTransitions and having semantically valid HTML Inputs with a
name
attribute that's eithermethod
oraction
, submitting a form results in a broken route:404 /[object%20HTMLInputElement] not found
This is caused by a concept called DOM clobbering and by incorrectly (but totally intuitively and understandably) assuming
form.action
is always the same a<form action="">
Where usually you'd except
form.action
to befoo
, the following DOM results inform.action
to point to theHTMLInputElement
instead.When trying to submit the form, it will read this element as the destination url instead.
What's the expected result?
The submit handler in View Transitions reading
method
andaction
should not assume readingform.action
andform.method
are safe to read in user land. Instead is should explicitly read the attribute. This follows the same pattern browser behavior withoutViewTranstions
enabled.Suggested changes in workaround.
astro/packages/astro/components/ViewTransitions.astro
Lines 112 to 113 in 8d5f3e8
Happy to create my first PR to Astro for this.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-3nkr3h?file=src%2Fpages%2Findex.astro
Participation
The text was updated successfully, but these errors were encountered: