MCPcopy Create free account
hub / github.com/TanStack/devtools / highlightAllIssues

Function highlightAllIssues

packages/devtools-a11y/src/core/utils/ui.utils.ts:392–460  ·  view source on GitHub ↗
(issues: Array<A11yIssue>)

Source from the content-addressed store, hash-verified

390 const existing = selectorIssues.get(selector) || []
391 // Avoid duplicate rule IDs for the same selector
392 if (!existing.some((e) => e.ruleId === issue.ruleId)) {
393 existing.push({ ruleId: issue.ruleId, impact })
394 selectorIssues.set(selector, existing)
395 }
396 }
397 }
398
399 // Highlight each selector with its most severe issue, but show all in tooltip
400 for (const [selector, issueList] of selectorIssues) {
401 // Skip empty lists (shouldn't happen, but guards against undefined)
402 if (issueList.length === 0) {
403 continue
404 }
405
406 // Find most severe impact for highlighting
407 const mostSevereImpact = issueList.reduce((max, issue) =>
408 SEVERITY_ORDER[issue.impact] > SEVERITY_ORDER[max.impact] ? issue : max,
409 ).impact
410
411 try {
412 const elements = document.querySelectorAll(selector)
413 if (elements.length === 0) {
414 continue
415 }
416
417 let highlightedCount = 0
418 elements.forEach((el) => {
419 // Skip elements inside devtools
420 if (isInsideDevtools(el)) {
421 return
422 }
423
424 el.classList.add(
425 HIGHLIGHT_CLASS,
426 `${HIGHLIGHT_CLASS}--${mostSevereImpact}`,
427 )
428
429 // Add tooltip to first highlighted element only, showing ALL issues
430 if (highlightedCount === 0) {
431 const tooltip = createTooltip(issueList, el)
432 if (tooltip) {
433 document.body.appendChild(tooltip)
434 }
435 }
436
437 highlightedCount++
438 })
439 } catch (error) {
440 console.error('[A11y Overlay] Error highlighting element:', error)
441 }
442 }
443}
444
445/**
446 * Clear all highlights from the page
447 */
448export function clearHighlights(): void {
449 // Remove highlight classes

Callers 2

handleIssueClickFunction · 0.90
createAllyValueFunction · 0.90

Calls 4

injectStylesFunction · 0.85
clearHighlightsFunction · 0.85
createTooltipFunction · 0.85
isInsideDevtoolsFunction · 0.70

Tested by

no test coverage detected