You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Register a directive that has unrecognized properties. For example, a directive that has both a Vue3-style "mounted" method and a Vue2-style "bind", which one might try to do to write a plugin that's compatible with both Vue2 and Vue3. But literally any property that isn't "beforeMount", "mounted", "beforeUpdate", "updated", "beforeUnmount" or "unmounted" will cause this crash.
app.directive( 'foo', {
mounted( el ) {
el.innerHTML = 'example';
bind( el ) {
el.innerHTML = 'example2';
}
} );
Then use the directive in a component somewhere (e.g. <p v-foo />)
What is expected?
Either the directive just works ("mounted" is used and "bind" is ignored), or I get a reasonably clear error message that explains what I did wrong
What is actually happening?
Registering the directive doesn't fail, but using it causes a JS error while rendering: TypeError: Cannot destructure 'directiveToVnodeHooksMap[key]' as it is undefined.
Version
3.0.0-alpha.7
Reproduction link
https://jsfiddle.net/catrope/s0th46n2/11/
Steps to reproduce
Register a directive that has unrecognized properties. For example, a directive that has both a Vue3-style "mounted" method and a Vue2-style "bind", which one might try to do to write a plugin that's compatible with both Vue2 and Vue3. But literally any property that isn't "beforeMount", "mounted", "beforeUpdate", "updated", "beforeUnmount" or "unmounted" will cause this crash.
Then use the directive in a component somewhere (e.g.
<p v-foo />
)What is expected?
Either the directive just works ("mounted" is used and "bind" is ignored), or I get a reasonably clear error message that explains what I did wrong
What is actually happening?
Registering the directive doesn't fail, but using it causes a JS error while rendering: TypeError: Cannot destructure 'directiveToVnodeHooksMap[key]' as it is undefined.
The destructuring that fails is here: https://github.com/vuejs/vue-next/blob/52cc7e823148289b3dcdcb6b521984ab815fce79/packages/runtime-core/src/directives.ts#L130
It fails because it expects every single key in dir to also exist in directiveToVnodeHooksMap, and it doesn't check that assumption.
The text was updated successfully, but these errors were encountered: