From: Thorsten Lünborg Date: Wed, 24 Feb 2021 19:51:19 +0000 (+0100) Subject: fix(runtime-dom): ensure readonly type prop on textarea is handled patched as attribu... X-Git-Tag: v3.0.6~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5d147c57f75ca38cc334bb27b61a8bc153494bd;p=thirdparty%2Fvuejs%2Fcore.git fix(runtime-dom): ensure readonly type prop on textarea is handled patched as attribute (#2888) close #2766 Co-authored-by: Thorsten Luenborg --- diff --git a/packages/runtime-dom/__tests__/patchProps.spec.ts b/packages/runtime-dom/__tests__/patchProps.spec.ts index 962d55e882..bec0f9ba34 100644 --- a/packages/runtime-dom/__tests__/patchProps.spec.ts +++ b/packages/runtime-dom/__tests__/patchProps.spec.ts @@ -149,4 +149,11 @@ describe('runtime-dom: props patching', () => { patchProp(el, 'form', 'foo', null) expect(el.getAttribute('form')).toBe(null) }) + + 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 848ee160a8..6842b98c2b 100644 --- a/packages/runtime-dom/src/patchProp.ts +++ b/packages/runtime-dom/src/patchProp.ts @@ -115,5 +115,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 }