MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / element

Method element

src/monogatari.ts:2264–2284  ·  view source on GitHub ↗
(pure = false, handled = false)

Source from the content-addressed store, hash-verified

2262 static element (pure: true, handled?: boolean): HTMLElement | null;
2263 static element (pure: false, handled?: boolean): DOM;
2264 static element (pure = false, handled = false): HTMLElement | DOM | null {
2265 let element: HTMLElement | DOM | null;
2266 let exists: boolean;
2267
2268 if (pure === true) {
2269 element = document.querySelector ('visual-novel') as HTMLElement;
2270 exists = element !== null;
2271 } else {
2272 element = $_('visual-novel');
2273 exists = element.length > 0;
2274 }
2275
2276 // In some cases, the user might be trying to execute an action using the
2277 // main element when the DOM has not been loaded yet, thus causing an
2278 // error since the element does not exists yet.
2279 if (exists === false && handled === false) {
2280 FancyError.show ('engine:element:not_ready', {});
2281 }
2282
2283 return element;
2284 }
2285
2286 static on (event: string, target: string | EventCallback, callback?: EventCallback): void {
2287 const element = this.element() as DOM;

Callers 8

widthMethod · 0.95
heightMethod · 0.95
setupMethod · 0.95
onMethod · 0.95
offMethod · 0.95
triggerMethod · 0.95
initMethod · 0.95
input.spec.jsFile · 0.45

Calls 1

showMethod · 0.45

Tested by

no test coverage detected