mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 22:17:40 +08:00
chore(ssr): fix document.body reference (#18863)
This commit is contained in:
@ -5,17 +5,17 @@ export const raf = (h: any) => {
|
||||
return (win.__zone_symbol__requestAnimationFrame) ? win.__zone_symbol__requestAnimationFrame(h) : requestAnimationFrame(h);
|
||||
};
|
||||
|
||||
export function proxyMethod(ctrlName: string, doc: Document, methodName: string, ...args: any[]) {
|
||||
export const proxyMethod = (ctrlName: string, doc: Document, methodName: string, ...args: any[]) => {
|
||||
const controller = ensureElementInBody(ctrlName, doc);
|
||||
return controller.componentOnReady()
|
||||
.then(() => (controller as any)[methodName].apply(controller, args));
|
||||
}
|
||||
};
|
||||
|
||||
export function ensureElementInBody(elementName: string, doc: Document) {
|
||||
export const ensureElementInBody = (elementName: string, doc: Document) => {
|
||||
let element = doc.querySelector(elementName);
|
||||
if (!element) {
|
||||
element = doc.createElement(elementName);
|
||||
doc.body.appendChild(element);
|
||||
}
|
||||
return element as HTMLStencilElement;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user