MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / getElementName

Function getElementName

packages/parsers/src/htmlParser.ts:70–87  ·  view source on GitHub ↗
(el: Element)

Source from the content-addressed store, hash-verified

68}
69
70function getElementName(el: Element): string {
71 const dataName = el.getAttribute("data-name");
72 if (dataName) return dataName;
73
74 const type = getElementType(el);
75 if (type === "text") {
76 const text = el.textContent?.trim().slice(0, 30) || "Text";
77 return text.length === 30 ? text + "..." : text;
78 }
79
80 const src = el.getAttribute("src");
81 if (src) {
82 const filename = src.split("/").pop() || src;
83 return filename.split("?")[0] ?? filename;
84 }
85
86 return el.id || el.className?.toString().split(" ")[0] || "Element";
87}
88
89function getZIndex(el: Element): number {
90 const dataLayer = el.getAttribute("data-layer");

Callers 1

parseHtmlFunction · 0.85

Calls 2

getElementTypeFunction · 0.85
getAttributeMethod · 0.65

Tested by

no test coverage detected