Skip to content

Commit c5d147c

Browse files
LinusBorgThorsten Luenborg
and
Thorsten Luenborg
authored
fix(runtime-dom): ensure readonly type prop on textarea is handled patched as attribute (#2888)
close #2766 Co-authored-by: Thorsten Luenborg <[email protected]>
1 parent 4117def commit c5d147c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,11 @@ describe('runtime-dom: props patching', () => {
149149
patchProp(el, 'form', 'foo', null)
150150
expect(el.getAttribute('form')).toBe(null)
151151
})
152+
153+
test('readonly type prop on textarea', () => {
154+
const el = document.createElement('textarea')
155+
// just to verify that it doesn't throw when i.e. switching a dynamic :is from an 'input' to a 'textarea'
156+
// see https://github.com/vuejs/vue-next/issues/2766
157+
patchProp(el, 'type', 'text', null)
158+
})
152159
})

packages/runtime-dom/src/patchProp.ts

+5
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,10 @@ function shouldSetAsProp(
115115
return false
116116
}
117117

118+
// DOMprop "type" is readonly on textarea elements: https://github.com/vuejs/vue-next/issues/2766
119+
if (key === 'type' && el.tagName === 'TEXTAREA') {
120+
return false
121+
}
122+
118123
return key in el
119124
}

0 commit comments

Comments
 (0)