Use modifiers but not defining as props in children cause they are bind when v-bind $attrs
Version
3.0.7
Reproduction link
https://codesandbox.io/s/busy-chatelet-pccu6?file=/src/App.vue
Steps to reproduce
inspect inputs. You will see inputtopmodifiers="[object Object]"
.
I am trying to v-bind $attrs with inheriting false.
The modifier you see is the modifier I didn't define as props.
In this case is it normal the non define modifier is present when I v-bind="$attrs"
What is expected?
Should not inject non define modifiers when binding attrs in the final html
What is actually happening?
injecting inputtopmodifiers="[object Object]"
When it’s empty it should not be injected
On Wed, Mar 3, 2021 at 1:29 AM HcySunYang notifications@github.com wrote:
You can filter them out manually, and I'm not sure if they should be filtered out by default.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vuejs/vue-next/issues/3345#issuecomment-789473347, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYFLNDKEN3BLG7VPFGYFGDTBXJMXANCNFSM4YQQKLDQ .
can you clarify the steps: c_lick here, write this, ..._ and the expected vs actually happening: it displays x vs it should display y in the input. Thanks
The modifiers of v-modle
introduces additional props, e.g.
<Comp v-model.a.b="val" />
Will be compiled to:
createVNode(Comp, {
modelValue: _ctx.val,
"onUpdate:modelValue": $event => (_ctx.val = $event),
modelModifiers: { a: true, b: true }
})
If the Comp
component does not define modelModifiers
as props, then it will appear in $attrs
. I mean you can manually filter out modelModifiers
from $attrs
.
Thank's for your answer. Is it something that the user should take care of? @posva
Or Vue has to delete it? That's the point of my pull request.
I would say yes: the user should manually take care of them since by default one wants to propagate such modifiers with v-attrs
so you should define the prop like @HcySunYang proposed.
@HcySunYang unless you have any other idea, I think we can close this one