Skip to content

Commit

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

close #2766
  • Loading branch information
Thorsten Luenborg committed Dec 26, 2020
1 parent 92d7ad1 commit 0757ba8
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 @@ -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)
})
})
5 changes: 5 additions & 0 deletions packages/runtime-dom/src/patchProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 0757ba8

Please sign in to comment.