docs icon indicating copy to clipboard operation
docs copied to clipboard

setting vModel value in mounted hook may cause confusion

Open unbyte opened this issue 5 years ago • 4 comments

Version

https://github.com/vuejs/vue-next/commit/54ed7592e416fc411196e9b767aebcc4f2ca20d8

Reproduction link

https://jsfiddle.net/uL8f9e2d/

Steps to reproduce

  1. open the terminal, see the log

What is expected?

custom directive's mounted hook should be called after value is set

What is actually happening?

custom directive's mounted hook is called before value is set because v-test is before v-model in template

unbyte avatar Oct 11 '20 03:10 unbyte

Hmm, I'm not sure if it's something that needs to be "fixed" - in fact, this gives the custom directive the ability to do something in mounted before OR after v-model value is set, by adjusting the order of its position relative to v-model. This is the case with v-bind bindings too (which are now also order-sensitive in v3). "Fixing" this actually removes some capabilities.

yyx990803 avatar Oct 15 '20 16:10 yyx990803

We might need to explain this is big red letters in the docs though 😜

LinusBorg avatar Oct 15 '20 16:10 LinusBorg

I hold the same idea, so the title is may cause confusion. maybe it should be a documentation work, or let Vue remind devs in development mode that these are order-sensitive in an appropriate way?

unbyte avatar Oct 15 '20 16:10 unbyte

@ docs team: transferred as a placeholder that we should likely document this a a case where order of directives has an influence on behavior.

LinusBorg avatar Feb 24 '21 10:02 LinusBorg