Skip to content

Commit 00683fc

Browse files
authored
fix(runtime-dom): patch form as an attribute (#1788)
Close #1787
1 parent 2787c34 commit 00683fc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/runtime-dom/__tests__/patchProps.spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,12 @@ describe('runtime-dom: props patching', () => {
121121
patchProp(el, 'id', null, '')
122122
expect(el.hasAttribute('id')).toBe(true)
123123
})
124+
125+
test('form attribute', () => {
126+
const el = document.createElement('input')
127+
patchProp(el, 'form', null, 'foo')
128+
// non existant element
129+
expect(el.form).toBe(null)
130+
expect(el.getAttribute('form')).toBe('foo')
131+
})
124132
})

packages/runtime-dom/src/patchProp.ts

+6
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ function shouldSetAsProp(
9393
return false
9494
}
9595

96+
// #1787 form as an attribute must be a string, while it accepts an Element as
97+
// a prop
98+
if (key === 'form' && typeof value === 'string') {
99+
return false
100+
}
101+
96102
// #1526 <input list> must be set as attribute
97103
if (key === 'list' && el.tagName === 'INPUT') {
98104
return false

0 commit comments

Comments
 (0)