Skip to content

Commit

Permalink
fix(directive): shoul call beforeUnmount hook of directive on functio…
Browse files Browse the repository at this point in the history
…nal components
  • Loading branch information
gretzkiy committed Dec 12, 2024
1 parent 69397cc commit ee1ecf5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/component/engines/directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ ComponentEngine.directive = function directive(name: string, directive?: Directi

const
originalCreated = directive.created,
originalBeforeUnmount = directive.beforeUnmount,
originalUnmounted = directive.unmounted;

if (originalUnmounted == null) {
if (originalUnmounted == null && originalBeforeUnmount == null) {
return originalDirective.call(ctx, name, directive);
}

Expand All @@ -72,7 +73,8 @@ ComponentEngine.directive = function directive(name: string, directive?: Directi
if (vnode.virtualContext != null) {
vnode.virtualContext.unsafe.$once('[[BEFORE_DESTROY]]', (opts: Required<ComponentDestructorOptions>) => {
if (opts.shouldUnmountVNodes) {
originalUnmounted.apply(this, args);
originalBeforeUnmount?.apply(this, args);
originalUnmounted?.apply(this, args);
}
});
}
Expand Down

0 comments on commit ee1ecf5

Please sign in to comment.