fix(vue): lifecycle events are correctly fired in component context (#22348)

resolves #22338
This commit is contained in:
Liam DeBeasi
2020-10-21 11:22:52 -04:00
committed by GitHub
parent 1a2e5322fb
commit bcef804dea
10 changed files with 148 additions and 20 deletions

View File

@ -182,13 +182,13 @@ export const IonRouterOutlet = defineComponent({
if (enteringViewItem === leavingViewItem) return;
fireLifecycle(enteringViewItem.vueComponent, LIFECYCLE_WILL_ENTER);
fireLifecycle(enteringViewItem.vueComponentRef, LIFECYCLE_WILL_ENTER);
if (leavingViewItem) {
let animationBuilder = routerAnimation;
const leavingEl = leavingViewItem.ionPageElement;
fireLifecycle(leavingViewItem.vueComponent, LIFECYCLE_WILL_LEAVE);
fireLifecycle(leavingViewItem.vueComponentRef, LIFECYCLE_WILL_LEAVE);
/**
* If we are going back from a page that
@ -230,7 +230,7 @@ export const IonRouterOutlet = defineComponent({
}
}
fireLifecycle(leavingViewItem.vueComponent, LIFECYCLE_DID_LEAVE);
fireLifecycle(leavingViewItem.vueComponentRef, LIFECYCLE_DID_LEAVE);
} else {
/**
* If there is no leaving element, just show
@ -241,7 +241,7 @@ export const IonRouterOutlet = defineComponent({
requestAnimationFrame(() => enteringEl.classList.remove('ion-page-invisible'));
}
fireLifecycle(enteringViewItem.vueComponent, LIFECYCLE_DID_ENTER);
fireLifecycle(enteringViewItem.vueComponentRef, LIFECYCLE_DID_ENTER);
components.value = viewStacks.getChildrenToRender(id);
}
@ -359,6 +359,7 @@ export const IonRouterOutlet = defineComponent({
return h(
c.vueComponent,
{
ref: c.vueComponentRef,
key: c.pathname,
isInOutlet: true,
registerIonPage: (ionPageEl: HTMLElement) => registerIonPage(c, ionPageEl)