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

Function queryByAttr

packages/core/src/utils/cssSelector.ts:3–14  ·  view source on GitHub ↗
(
  root: ParentNode,
  attr: string,
  value: string,
  tag?: string,
)

Source from the content-addressed store, hash-verified

1// ponytail: queries DOM by exact attribute match without interpolating
2// the value into a selector string — zero injection surface.
3export function queryByAttr(
4 root: ParentNode,
5 attr: string,
6 value: string,
7 tag?: string,
8): Element | null {
9 const selector = tag ? `${tag}[${attr}]` : `[${attr}]`;
10 for (const el of root.querySelectorAll(selector)) {
11 if (el.getAttribute(attr) === value) return el;
12 }
13 return null;
14}

Callers 4

ensureExternalScriptTagFunction · 0.90
bundleToSingleHtmlFunction · 0.90
inlineSubCompositionsFunction · 0.90

Calls 1

getAttributeMethod · 0.65

Tested by

no test coverage detected