Skip to content

Commit 22ed9fb

Browse files
committed
Fixing bug with <form data-model not set to any value
1 parent 6afcd61 commit 22ed9fb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/LiveComponent/assets/src/dom_utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ export function getModelDirectiveFromInput(element: HTMLElement, throwOnMissing
7575
const formElement = element.closest('form');
7676
// require a <form data-model="*"> around elements in order to
7777
// activate automatic "data binding" via the "name" attribute
78-
if (formElement && formElement.dataset.model) {
79-
const directives = parseDirectives(formElement.dataset.model);
78+
if (formElement && ('model' in formElement.dataset)) {
79+
const directives = parseDirectives(formElement.dataset.model || '*');
8080
const directive = directives[0];
8181

8282
if (directive.args.length > 0 || directive.named.length > 0) {

src/LiveComponent/assets/test/controller/model.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe('LiveController data-model Tests', () => {
179179
it('falls back to using the name attribute when no data-model is present and <form data-model> is ancestor', async () => {
180180
const test = await createTest({ color: '' }, (data: any) => `
181181
<div ${initComponent(data)}>
182-
<form data-model="*">
182+
<form data-model>
183183
<input
184184
name="color"
185185
value="${data.color}"

0 commit comments

Comments
 (0)