-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Description
Test Version: v0.12.10
In v-if
, it will cache the linker if the constructor and the element's html are the same. However, the linker is relative to the host. It means it will lead to some hard-to-discover unexpected behaviours. For example as followed, the comp-b
in #two
won't fire any ready
/ attached
events! Because
- After the
#one
attached, the program will compile and link the#two
. - When binding the
v-if
directive forcomp-b
in#two
's template, the directive will fetch the linker from the cache (whose host is thecomp-a
in#one
!). - The directive invoke the
update
and compile and link thecomp-b
. - The
comp-b
will be added into#one
'scomp-a
's$children
list. - Then it will check if need to fire the
attached
event, however, because the host (thecomp-b
in#one
) is attached, it won't fire it!
<template id="comp-c">
<comp-a>
<comp-b v-if="some-condition-true">Something</comp-b>
</comp-a>
</template>
<template id="comp-a">
<content></content>
</template>
<template id="comp-b">
<content></content>
</template>
<body>
<div id="app">
<comp-c id="one"></comp-c>
<comp-c id="two"></comp-c>
</div>
</body>
Metadata
Metadata
Assignees
Labels
No labels