Subscribe on changes!

[Script Setup] Global directives collide with component's local vars

avatar
Apr 5th 2021

Version

3.0.11

Reproduction link

CodeSandbox will work as expected, as it's seemingly unable to parse the new script setup syntax: https://codesandbox.io/s/amazing-sun-nn9zt

Steps to reproduce

  1. Register a global directive, name it "focus" and listen for the callback.
  2. Create a SFC with the experimental "script setup" syntax and declare a variable with the same name as the global directive (focus).

What is expected?

The directive callback would be called.

What is actually happening?

The component's local variable seems to override the global directive, thus the callback never firing.

avatar
Apr 6th 2021

This seems inevitable, maybe we need to provide an appropriate warning message for this

avatar
Apr 6th 2021

Finally I came up with the solution https://github.com/vuejs/vue-next/pull/3546