MCPcopy Create free account
hub / github.com/ionic-team/ionic-framework / findCheckedOption

Function findCheckedOption

core/src/utils/watch-options.ts:37–52  ·  view source on GitHub ↗
(node: Node, tagName: string)

Source from the content-addressed store, hash-verified

35 * such as HTMLIonSelectOptionElement.
36 */
37export const findCheckedOption = <T extends HTMLElement & { value?: any | null }>(node: Node, tagName: string) => {
38 /**
39 * https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
40 * The above check ensures "node" is an Element (nodeType 1).
41 */
42 if (node.nodeType !== 1) {
43 return undefined;
44 }
45
46 // HTMLElement inherits from Element, so we cast "el" as T.
47 const el = node as T;
48
49 const options: T[] = el.tagName === tagName.toUpperCase() ? [el] : Array.from(el.querySelectorAll(tagName));
50
51 return options.find((o: T) => o.value === el.value);
52};

Callers 1

getSelectedOptionFunction · 0.85

Calls 1

fromMethod · 0.80

Tested by

no test coverage detected