Skip to content

Commit

Permalink
Only extract value meta when element is not a form, closes phoenixf…
Browse files Browse the repository at this point in the history
…ramework#2680

`extractMeta` receives a "root element".

When this element is an input, we want to retrieve the current value.

When the element is a form, `form.key` will look up any inputs in the
form with the name "key". If an input has the name "value", then we would
retrieve the input element *as the value*, instead of getting the value
of an input.

We explicitly avoid getting the value of a form to avoid this edgecase.

At time of writing, the value attribute is valid on button, data, input,
li, meter, option, progress and param tags.
  • Loading branch information
rktjmp committed Jun 10, 2023
1 parent b2ff167 commit 34e2029
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion assets/js/phoenix_live_view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ export default class View {
let name = el.attributes[i].name
if(name.startsWith(prefix)){ meta[name.replace(prefix, "")] = el.getAttribute(name) }
}
if(el.value !== undefined){
if(el.tagName !== "FORM" && el.value !== undefined){
if(!meta){ meta = {} }
meta.value = el.value

Expand Down

0 comments on commit 34e2029

Please sign in to comment.