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)
| Target | Type |
|---|---|
| escapeCSS | calls |
No incoming dependencies.