Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unresolved global directive leads to the Cannot read properties of undefined (reading 'deep') error #6340

Closed
mefcorvi opened this issue Jul 22, 2022 · 0 comments · Fixed by #6671

Comments

@mefcorvi
Copy link
Contributor

Vue version

3.2.73

Link to minimal reproduction

https://sfc.vuejs.org/#eNo9jUkOwjAMRa8SeU2SfRUhcY9sCjWQqhlku2FR5e4kCHVn/+H9A26lmLojTOAEY9lmwatPSrklVFV1yqIJOW8VF2W74+wZgwuEWDKJjnMxK+fUKcco+7/BHib1U4bWZ8bv4S1SeLKWn4+xvbLJ9LL9MrQnCRENctR3yh9G6mAPA9F8atC+EZ887A==

Steps to reproduce

Add any nonexistent custom directive to any element in the SFC file.

<template>
  <div v-not-resolved>Test</div>
</template>

What is expected?

An error with a correct message about unresolved directive.

What is actually happening?

You can see a warning Failed to resolve directive: not-resolved in the logs but then Cannot read properties of undefined (reading 'deep') error is thrown at this line:

Problem is that SFC compiler generates something like this:

  const _directive_not_resolved = _resolveDirective("not-resolved")

  return _withDirectives((_openBlock(), _createElementBlock("div", null, _hoisted_2)), [
    [_directive_not_resolved]
  ])

resolveDirective tries to resolve directive, can't find it, writes a warning to the logs and returns undefined. Then function withDirectives fails because it is assuming that all directives are correctly resolved.

This issue is also related to #4054 - resolveDirective really returns Directive | undefined and withDirectives expects directives: Array<[Directive, ...]>.

System Info

No response

Any additional comments?

No response

cexbrayat added a commit to cexbrayat/vue-next that referenced this issue Sep 15, 2022
Fixes vuejs#6340

This commit improves the case when a directive is not found in a template.
As `resolveDirective` returns `undefined`, some code was failing with the following error:

```
TypeError: Cannot read properties of undefined (reading 'deep')
```
cexbrayat added a commit to cexbrayat/vue-next that referenced this issue Oct 6, 2022
Fixes vuejs#6340

This commit improves the case when a directive is not found in a template.
As `resolveDirective` returns `undefined`, some code was failing with the following error:

```
TypeError: Cannot read properties of undefined (reading 'deep')
```
yyx990803 pushed a commit that referenced this issue Nov 8, 2022
fix #6340

This commit improves the case when a directive is not found in a template.
As `resolveDirective` returns `undefined`, some code was failing with the following error:

```
TypeError: Cannot read properties of undefined (reading 'deep')
```
chrislone pushed a commit to chrislone/core that referenced this issue Feb 4, 2023
fix vuejs#6340

This commit improves the case when a directive is not found in a template.
As `resolveDirective` returns `undefined`, some code was failing with the following error:

```
TypeError: Cannot read properties of undefined (reading 'deep')
```
zhangzhonghe pushed a commit to zhangzhonghe/core that referenced this issue Apr 12, 2023
fix vuejs#6340

This commit improves the case when a directive is not found in a template.
As `resolveDirective` returns `undefined`, some code was failing with the following error:

```
TypeError: Cannot read properties of undefined (reading 'deep')
```
@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant