@surea11y/core 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +25 -2
  2. package/docs/ENGINE_OPTIONS.md +2 -0
  3. package/docs/LIMITATIONS.md +1 -1
  4. package/package.json +1 -1
  5. package/src/checks/automatic/aria-allowed-attr.js +5 -4
  6. package/src/checks/automatic/aria-allowed-role.js +5 -4
  7. package/src/checks/automatic/aria-braille-equivalent.js +3 -4
  8. package/src/checks/automatic/aria-conditional-attr.js +3 -4
  9. package/src/checks/automatic/aria-deprecated-role.js +2 -3
  10. package/src/checks/automatic/aria-prohibited-attr.js +5 -4
  11. package/src/checks/automatic/aria-prohibited-children.js +2 -3
  12. package/src/checks/automatic/aria-required-attr.js +2 -3
  13. package/src/checks/automatic/aria-required-children.js +2 -3
  14. package/src/checks/automatic/aria-required-parent.js +3 -4
  15. package/src/checks/automatic/aria-roles-valid.js +2 -3
  16. package/src/checks/automatic/aria-valid-attr-value.js +5 -4
  17. package/src/checks/automatic/aria-valid-attr.js +5 -4
  18. package/src/checks/automatic/autocomplete-valid.js +2 -3
  19. package/src/checks/automatic/avoid-inline-spacing.js +2 -3
  20. package/src/checks/automatic/binary-control-name-present.js +2 -3
  21. package/src/checks/automatic/button-name-present.js +14 -4
  22. package/src/checks/automatic/bypass-blocks-present.js +35 -7
  23. package/src/checks/automatic/combobox-name-present.js +2 -3
  24. package/src/checks/automatic/definition-list-children-valid.js +2 -3
  25. package/src/checks/automatic/deprecated-elements-not-used.js +5 -4
  26. package/src/checks/automatic/dialog-name-present.js +2 -3
  27. package/src/checks/automatic/dlitem-parent-valid.js +2 -3
  28. package/src/checks/automatic/form-control-single-label.js +2 -3
  29. package/src/checks/automatic/iframe-focusable-content.js +2 -3
  30. package/src/checks/automatic/iframe-name-present.js +2 -3
  31. package/src/checks/automatic/iframe-title-unique.js +5 -5
  32. package/src/checks/automatic/label-in-name.js +7 -8
  33. package/src/checks/automatic/link-in-text-block.js +2 -3
  34. package/src/checks/automatic/link-name-present.js +16 -4
  35. package/src/checks/automatic/list-children-valid.js +2 -3
  36. package/src/checks/automatic/listbox-name-present.js +2 -3
  37. package/src/checks/automatic/listitem-parent-valid.js +2 -3
  38. package/src/checks/automatic/menuitem-name-present.js +2 -3
  39. package/src/checks/automatic/meter-name-present.js +2 -3
  40. package/src/checks/automatic/nested-interactive-controls-absent.js +2 -3
  41. package/src/checks/automatic/option-name-present.js +2 -3
  42. package/src/checks/automatic/progressbar-name-present.js +2 -3
  43. package/src/checks/automatic/searchbox-name-present.js +2 -3
  44. package/src/checks/automatic/server-side-image-map-absent.js +2 -3
  45. package/src/checks/automatic/slider-name-present.js +2 -3
  46. package/src/checks/automatic/spinbutton-name-present.js +2 -3
  47. package/src/checks/automatic/summary-name-present.js +2 -3
  48. package/src/checks/automatic/tab-name-present.js +2 -3
  49. package/src/checks/automatic/table-headers-attr-valid.js +5 -4
  50. package/src/checks/automatic/table-th-has-data-cells.js +5 -4
  51. package/src/checks/automatic/td-has-header.js +2 -3
  52. package/src/checks/automatic/textbox-name-present.js +2 -3
  53. package/src/checks/automatic/tooltip-name-present.js +2 -3
  54. package/src/checks/automatic/treeitem-name-present.js +2 -3
  55. package/src/checks/automatic/valid-lang.js +2 -3
  56. package/src/checks/manual/accesskeys-manual.js +1 -7
  57. package/src/checks/manual/aria-checked-state-mismatch-manual.js +7 -6
  58. package/src/checks/manual/aria-text-manual.js +2 -3
  59. package/src/checks/manual/focus-order-semantics-manual.js +2 -3
  60. package/src/checks/manual/identical-links-same-purpose-manual.js +2 -3
  61. package/src/checks/manual/image-redundant-alt-manual.js +2 -3
  62. package/src/checks/manual/label-title-only-manual.js +2 -3
  63. package/src/checks/manual/link-name-quality-manual.js +2 -3
  64. package/src/checks/manual/mouse-only-event-handlers-manual.js +2 -3
  65. package/src/checks/manual/no-autoplay-audio-manual.js +2 -3
  66. package/src/checks/manual/p-as-heading-manual.js +2 -3
  67. package/src/checks/manual/page-has-heading-one-manual.js +31 -2
  68. package/src/checks/manual/presentation-role-conflict-manual.js +3 -4
  69. package/src/checks/manual/scrollable-region-focusable-manual.js +2 -3
  70. package/src/checks/manual/skip-link-manual.js +91 -9
  71. package/src/checks/manual/table-duplicate-name-manual.js +2 -3
  72. package/src/checks/manual/table-fake-caption-manual.js +2 -3
  73. package/src/checks/manual/video-caption-manual.js +2 -3
  74. package/src/core/dom-helpers.js +89 -3
  75. package/src/core/dom-runner.js +19 -0
  76. package/src/core.js +962 -481
  77. package/src/i18n/en.js +4 -2
  78. package/src/i18n/fr.js +4 -2
@@ -48,6 +48,9 @@ function runCore(pageUrl, contextSelector, engineOptions, runOnly, CHECK_DEFS, R
48
48
 
49
49
  // Default on: opt OUT with `includeShadowDom: false`, not opt in.
50
50
  const includeShadowDom = !(engineOptionsResolved && engineOptionsResolved.includeShadowDom === false);
51
+ // Default off: hidden/collapsed content is excluded from rule evaluation
52
+ // unless the caller explicitly opts in.
53
+ const includeHiddenElements = !!(engineOptionsResolved && engineOptionsResolved.includeHiddenElements === true);
51
54
  const excludeSelectors = normalizeSelectorList(engineOptionsResolved && engineOptionsResolved.excludeSelectors);
52
55
 
53
56
  const url = pageUrl || (document.location && document.location.href) || null;
@@ -58,11 +61,27 @@ function runCore(pageUrl, contextSelector, engineOptions, runOnly, CHECK_DEFS, R
58
61
  ? engineOptionsResolved.timestamp.trim()
59
62
  : null;
60
63
 
64
+ // createDomHelpers()/createContrastHelpers() persist their element-keyed
65
+ // caches (outerHtmlCache, selectorCache, etc.) on window.__a11ycoreSharedCache
66
+ // so multiple helper instances created *within this run* can share them
67
+ // deterministically. But a window/document is frequently reused across
68
+ // SEPARATE runs -- e.g. Jest's jsdom environment creates one window per
69
+ // test file, and mutating document.body between it() blocks is standard.
70
+ // Those caches are keyed by element reference, not content, so a run that
71
+ // reuses an already-cached element (document.body never changes identity)
72
+ // would otherwise read stale data cached by an earlier, unrelated run on
73
+ // the same window. Clearing at the start of every run keeps sharing scoped
74
+ // to "this run" as intended, without leaking across runs.
75
+ try {
76
+ if (window && window.__a11ycoreSharedCache) window.__a11ycoreSharedCache = {};
77
+ } catch {}
78
+
61
79
  const sharedHelpers = createDomHelpers({
62
80
  document,
63
81
  window,
64
82
  root: roots,
65
83
  includeShadowDom,
84
+ includeHiddenElements,
66
85
  excludeSelectors,
67
86
  // Optional perf counters (bench/debug only). Deterministic and per-run.
68
87
  perfStats: !!(engineOptionsResolved && engineOptionsResolved.perfStats)