[Bug] `undefined` attrs are not being passed
Version
3.1.1
Reproduction link
https://github.com/wenfangdu/vue-attrs-repro
Steps to reproduce
Please use the repro link, this behavior doesn't exist in v3.0.11
.
What is expected?
Attrs with undefined
are being passed.
What is actually happening?
Attrs with undefined
are not being passed.
This makes attrs and props have a consistent behavior after https://github.com/vuejs/vue-next/issues/3288: you shouldn't differentiate the cases where undefined
is explicitly passed vs the prop is missing
@posva Please pardon me, am I understanding consistency wrong? I've updated my repro, please have a look.
import { defineComponent } from 'vue'
export default defineComponent({
inheritAttrs: false,
props: {
baz: String,
},
setup(props, { attrs }) {
// 👇 logs { baz: undefined }
console.log(props)
// 👇 logs { foo: 'foo' }, NOT { foo: 'foo', bar: undefined }
console.log(attrs)
return () => <div>Comp</div>
},
})
@posva Thanks for clarifying, another change I overlooked is the following, which caused the confusion, attaching it here for future reference: