mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 14:01:20 +08:00
fix(prerender): local references to window/document
This commit is contained in:
@ -6,6 +6,8 @@ import { Component, Listen, Prop, State } from '@stencil/core';
|
||||
})
|
||||
export class MenuToggle {
|
||||
|
||||
@Prop({ context: 'document' }) doc: Document;
|
||||
|
||||
@State() visible = false;
|
||||
|
||||
/**
|
||||
@ -25,7 +27,7 @@ export class MenuToggle {
|
||||
|
||||
@Listen('child:click')
|
||||
async onClick() {
|
||||
const menuCtrl = await getMenuController();
|
||||
const menuCtrl = await getMenuController(this.doc);
|
||||
if (menuCtrl) {
|
||||
const menu = menuCtrl.get(this.menu);
|
||||
if (menu && menu.isActive()) {
|
||||
@ -38,7 +40,7 @@ export class MenuToggle {
|
||||
@Listen('body:ionMenuChange')
|
||||
@Listen('body:ionSplitPaneVisible')
|
||||
async updateVisibility() {
|
||||
const menuCtrl = await getMenuController();
|
||||
const menuCtrl = await getMenuController(this.doc);
|
||||
if (menuCtrl) {
|
||||
const menu = menuCtrl.get(this.menu);
|
||||
if (menu && menu.isActive()) {
|
||||
@ -60,8 +62,8 @@ export class MenuToggle {
|
||||
|
||||
}
|
||||
|
||||
function getMenuController(): Promise<HTMLIonMenuControllerElement|undefined> {
|
||||
const menuControllerElement = document.querySelector('ion-menu-controller');
|
||||
function getMenuController(doc: Document): Promise<HTMLIonMenuControllerElement|undefined> {
|
||||
const menuControllerElement = doc.querySelector('ion-menu-controller');
|
||||
if (!menuControllerElement) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
Reference in New Issue
Block a user