| 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; |