MCPcopy Create free account
hub / github.com/angular/components / getElementByTagName

Function getElementByTagName

src/cdk/schematics/utils/html-manipulation.ts:90–105  ·  view source on GitHub ↗

Finds an element by its tag name.

(tagName: string, htmlContent: string)

Source from the content-addressed store, hash-verified

88
89/** Finds an element by its tag name. */
90function getElementByTagName(tagName: string, htmlContent: string): Element | null {
91 const document = parseHtml(htmlContent, {sourceCodeLocationInfo: true});
92 const nodeQueue = [...document.childNodes];
93
94 while (nodeQueue.length) {
95 const node = nodeQueue.shift() as Element;
96
97 if (node.nodeName.toLowerCase() === tagName) {
98 return node;
99 } else if (node.childNodes) {
100 nodeQueue.push(...node.childNodes);
101 }
102 }
103
104 return null;
105}

Callers 2

getHtmlHeadTagElementFunction · 0.85
addBodyClassFunction · 0.85

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected