Textarea attribute :type="null" throws error
Version
3.0.4
Reproduction link
https://codesandbox.io/s/affectionate-ganguly-q4153?file=/src/App.vue
Steps to reproduce
Insert and specify type attribute as null or undefined.
What is expected?
Attribute has not been rendered according with the Vue 3 documentation - https://v3.vuejs.org/guide/template-syntax.html#attributes
What is actually happening?
Throws the error: Uncaught (in promise) TypeError: Cannot set property type of #
Vue 2 app in the same case works correct
You cannot set the type
of a textarea: https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element. It's a readonly property.
Maybe the attribute shouldn't be set if the value is null or undefined
Yes, it is. But I can't remove it another way. Example:
<template>
<component
:is="tag"
:type="tag === 'input' ? 'text' : null"
/>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
props: {
tag: {
type: String,
default: 'input', // or textarea
},
},
});
</script>