Skip to content

Commit

Permalink
fix(runtime-dom): ensure readonly type prop on textarea is handled pa…
Browse files Browse the repository at this point in the history
…tched as attribute (#2888)

close #2766

Co-authored-by: Thorsten Luenborg <t.luneborg@googlemail.com>
  • Loading branch information
LinusBorg and Thorsten Luenborg authored Feb 24, 2021
1 parent 4117def commit c5d147c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/runtime-dom/__tests__/patchProps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
5 changes: 5 additions & 0 deletions packages/runtime-dom/src/patchProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit c5d147c

Please sign in to comment.