tryId function ✓ 100.0%

Last updated: 2026-03-05T12:26:14.062Z

Metrics

LOC: 12 Complexity: 3 Params: 1 Coverage: 100.0% (3/3 lines, 79x executed)

Signature

tryId(el: Element): : SmartSelector | null

Source Code

function tryId(el: Element): SmartSelector | null {
  if (!el.id) return null;

  // Skip auto-generated IDs (common patterns: :r0:, react-xxx, ember123, etc.)
  if (/^:r\d|^(react|ember|ng-|js-)[\w-]*\d/i.test(el.id)) return null;

  return {
    value: `#${escapeCSS(el.id)}`,
    strategy: "id",
    description: `id="${el.id}"`,
  };
}

Dependencies (Outgoing)

graph LR tryId["tryId"] escapeCSS["escapeCSS"] tryId -->|calls| escapeCSS style tryId fill:#dbeafe,stroke:#2563eb,stroke-width:2px click tryId "b3cdceee83420d12.html" click escapeCSS "44646aa96f30257e.html"
TargetType
escapeCSS calls

No incoming dependencies.