buildQuickSelector function presentation ✓ 100.0%

Last updated: 2026-03-01T23:25:47.080Z

Metrics

LOC: 16 Complexity: 6 Params: 1 Coverage: 100.0% (9/9 lines, 12x executed)

Signature

buildQuickSelector(el: Element): : string

Source Code

function buildQuickSelector(el: Element): string {
  if (el.id) return `#${CSS.escape(el.id)}`;

  const testId =
    el.getAttribute("data-testid") ?? el.getAttribute("data-test-id");
  if (testId) return `[data-testid="${CSS.escape(testId)}"]`;

  const name = el.getAttribute("name");
  if (name) return `${el.tagName.toLowerCase()}[name="${CSS.escape(name)}"]`;

  const tag = el.tagName.toLowerCase();
  const type = el.getAttribute("type");
  if (type) return `${tag}[type="${CSS.escape(type)}"]`;

  return tag;
}

No outgoing dependencies.

No incoming dependencies.