MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / getElement

Function getElement

static/bootstrap-utils.ts:58–74  ·  view source on GitHub ↗

* Helper method to get an HTMLElement from various input types * * This is a core utility function that bridges jQuery objects with native DOM elements, * allowing our codebase to work with both paradigms while the Bootstrap 5 API requires * native DOM elements. * * @param elementOrSelector El

(elementOrSelector: string | HTMLElement | JQuery)

Source from the content-addressed store, hash-verified

56 * @returns HTMLElement or null
57 */
58function getElement(elementOrSelector: string | HTMLElement | JQuery): HTMLElement | null {
59 if (!elementOrSelector) return null;
60
61 if (typeof elementOrSelector === 'string') {
62 return document.querySelector(elementOrSelector as string);
63 }
64
65 if (elementOrSelector instanceof HTMLElement) {
66 return elementOrSelector;
67 }
68
69 if (elementOrSelector instanceof $) {
70 return (elementOrSelector as JQuery)[0] as HTMLElement;
71 }
72
73 return null;
74}
75
76/**
77 * Private helper that sets an event handler on a single DOM element

Callers 11

getModalInstanceFunction · 0.85
showModalFunction · 0.85
hideModalFunction · 0.85
showToastFunction · 0.85
hideToastFunction · 0.85
getDropdownInstanceFunction · 0.85
showDropdownFunction · 0.85
hideDropdownFunction · 0.85
initPopoverFunction · 0.85
initPopoverIfExistsFunction · 0.85
getPopoverInstanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected