MCPcopy
hub / github.com/ionic-team/ionic-framework / createOverlay

Function createOverlay

core/src/utils/overlays.ts:122–145  ·  view source on GitHub ↗
(
  tagName: string,
  opts: object | undefined
)

Source from the content-addressed store, hash-verified

120};
121
122export const createOverlay = <T extends HTMLIonOverlayElement>(
123 tagName: string,
124 opts: object | undefined
125): Promise<T> => {
126 // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
127 if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined') {
128 return window.customElements.whenDefined(tagName).then(() => {
129 const element = document.createElement(tagName) as HTMLIonOverlayElement;
130 element.classList.add('overlay-hidden');
131
132 /**
133 * Convert the passed in overlay options into props
134 * that get passed down into the new overlay.
135 */
136 Object.assign(element, { ...opts, hasController: true });
137
138 // append the overlay element to the document body
139 getAppRoot(document).appendChild(element);
140
141 return new Promise((resolve) => componentOnReady(element, resolve));
142 });
143 }
144 return Promise.resolve() as any;
145};
146
147const isOverlayHidden = (overlay: Element) => overlay.classList.contains('overlay-hidden');
148

Callers 1

createFunction · 0.85

Calls 3

componentOnReadyFunction · 0.90
getAppRootFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected