Subscribe on changes!

Use modifiers but not defining as props in children cause they are bind when v-bind $attrs

avatar
Mar 3rd 2021

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]"

avatar
Mar 3rd 2021

You can filter them out manually, and I'm not sure if they should be filtered out by default.

avatar
Mar 3rd 2021

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 .

avatar
Mar 3rd 2021

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

avatar
Mar 3rd 2021

I have updated the steps thanks

avatar
Mar 4th 2021

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.

avatar
Mar 4th 2021

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.

avatar
Mar 4th 2021

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

avatar
Mar 4th 2021

If it's something that the user should be aware sure close it and thanks for your answers :)