Skip to content

Commit 14851f5

Browse files
fix: fixed custom directives migration guide
1 parent 5a47a77 commit 14851f5

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

src/guide/migration/custom-directives.md

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ badges:
1010
Here is a quick summary of what has changed:
1111

1212
- API has been renamed to better align with component lifecycle
13-
- Custom directives will be controlled by child component via `v-bind="$attrs"`
1413

1514
For more information, read on!
1615

@@ -103,26 +102,6 @@ mounted(el, binding, vnode) {
103102
}
104103
```
105104

106-
## Implementation Details
107-
108-
In Vue 3, we're now supporting fragments, which allow us to return more than one DOM node per component. You can imagine how handy that is for something like a component with multiple `<li>` elements or the children elements of a table:
109-
110-
```html
111-
<template>
112-
<li>Hello</li>
113-
<li>Vue</li>
114-
<li>Devs!</li>
115-
</template>
116-
```
117-
118-
As wonderfully flexible as this is, we can potentially encounter a problem with a custom directive that could have multiple root nodes.
119-
120-
As a result, custom directives are now included as part of a virtual DOM node’s data. When a custom directive is used on a component, hooks are passed down to the component as extraneous props and end up in `this.$attrs`.
121-
122-
This also means it's possible to directly hook into an element's lifecycle like this in the template, which can be handy when a custom directive is too involved:
123-
124-
```html
125-
<div @vnodeMounted="myHook" />
126-
```
127-
128-
This is consistent with the attribute fallthrough behavior, so when a child component uses `v-bind="$attrs"` on an inner element, it will apply any custom directives used on it as well.
105+
:::warning
106+
With [fragments](/guide/migration/fragments.html#overview) support, components can potentially have more than one root nodes. When applied to a multi-root component, directive will be ignored and the warning will be thrown.
107+
:::

0 commit comments

Comments
 (0)