Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/runtime-dom/__tests__/patchProps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,12 @@ describe('runtime-dom: props patching', () => {
// see https://github.com/vuejs/vue-next/issues/2766
patchProp(el, 'type', 'text', null)
})

test('input with size', () => {
const el = document.createElement('input')
patchProp(el, 'size', null, 100)
expect(el.size).toBe(100)
patchProp(el, 'size', 100, null)
expect(el.getAttribute('size')).toBe(null)
})
})
5 changes: 4 additions & 1 deletion packages/runtime-dom/src/modules/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ export function patchDOMProp(
return
} else if (type === 'number') {
// e.g. <img :width="null">
el[key] = 0
// the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
try {
el[key] = 0
} catch {}
el.removeAttribute(key)
return
}
Expand Down