diff --git a/packages/runtime-dom/__tests__/patchProps.spec.ts b/packages/runtime-dom/__tests__/patchProps.spec.ts index 687b2b79056..ad41aed0e7a 100644 --- a/packages/runtime-dom/__tests__/patchProps.spec.ts +++ b/packages/runtime-dom/__tests__/patchProps.spec.ts @@ -146,4 +146,11 @@ describe('runtime-dom: props patching', () => { expect(el.form).toBe(null) expect(el.getAttribute('form')).toBe('foo') }) + + test('readonly type prop on textarea', () => { + const el = document.createElement('textarea') + // just to verify that it doesn't throw when i.e. switching a dynamic :is from an 'input' to a 'textarea' + // see https://github.com/vuejs/vue-next/issues/2766 + patchProp(el, 'type', 'text', null) + }) }) diff --git a/packages/runtime-dom/src/patchProp.ts b/packages/runtime-dom/src/patchProp.ts index 91f6ed526dc..2157e3af3c3 100644 --- a/packages/runtime-dom/src/patchProp.ts +++ b/packages/runtime-dom/src/patchProp.ts @@ -109,5 +109,10 @@ function shouldSetAsProp( return false } + // DOMprop "type" is readonly on textarea elements: https://github.com/vuejs/vue-next/issues/2766 + if (key === 'type' && el.tagName === 'TEXTAREA') { + return false + } + return key in el }