accented 0.0.2 → 1.0.1

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 (217) hide show
  1. package/NOTICE +14 -0
  2. package/README.md +44 -187
  3. package/dist/accented.d.ts +8 -8
  4. package/dist/accented.d.ts.map +1 -1
  5. package/dist/accented.js +37 -30
  6. package/dist/accented.js.map +1 -1
  7. package/dist/common/strings.d.ts +2 -0
  8. package/dist/common/strings.d.ts.map +1 -0
  9. package/dist/common/strings.js +2 -0
  10. package/dist/common/strings.js.map +1 -0
  11. package/dist/common/tokens.d.ts +7 -0
  12. package/dist/common/tokens.d.ts.map +1 -0
  13. package/dist/common/tokens.js +8 -0
  14. package/dist/common/tokens.js.map +1 -0
  15. package/dist/constants.d.ts +2 -1
  16. package/dist/constants.d.ts.map +1 -1
  17. package/dist/constants.js +2 -1
  18. package/dist/constants.js.map +1 -1
  19. package/dist/dom-updater.d.ts +1 -1
  20. package/dist/dom-updater.d.ts.map +1 -1
  21. package/dist/dom-updater.js +73 -31
  22. package/dist/dom-updater.js.map +1 -1
  23. package/dist/elements/accented-dialog.d.ts +18 -10
  24. package/dist/elements/accented-dialog.d.ts.map +1 -1
  25. package/dist/elements/accented-dialog.js +116 -95
  26. package/dist/elements/accented-dialog.js.map +1 -1
  27. package/dist/elements/accented-trigger.d.ts +14 -9
  28. package/dist/elements/accented-trigger.d.ts.map +1 -1
  29. package/dist/elements/accented-trigger.js +83 -24
  30. package/dist/elements/accented-trigger.js.map +1 -1
  31. package/dist/fullscreen-listener.d.ts +2 -0
  32. package/dist/fullscreen-listener.d.ts.map +1 -0
  33. package/dist/fullscreen-listener.js +17 -0
  34. package/dist/fullscreen-listener.js.map +1 -0
  35. package/dist/intersection-observer.d.ts +1 -1
  36. package/dist/intersection-observer.d.ts.map +1 -1
  37. package/dist/intersection-observer.js +12 -6
  38. package/dist/intersection-observer.js.map +1 -1
  39. package/dist/log-and-rethrow.d.ts +1 -1
  40. package/dist/log-and-rethrow.d.ts.map +1 -1
  41. package/dist/log-and-rethrow.js +2 -3
  42. package/dist/log-and-rethrow.js.map +1 -1
  43. package/dist/logger.d.ts +4 -1
  44. package/dist/logger.d.ts.map +1 -1
  45. package/dist/logger.js +6 -3
  46. package/dist/logger.js.map +1 -1
  47. package/dist/register-elements.d.ts +1 -1
  48. package/dist/register-elements.d.ts.map +1 -1
  49. package/dist/register-elements.js +6 -7
  50. package/dist/register-elements.js.map +1 -1
  51. package/dist/resize-listener.d.ts +1 -1
  52. package/dist/resize-listener.d.ts.map +1 -1
  53. package/dist/resize-listener.js +3 -4
  54. package/dist/resize-listener.js.map +1 -1
  55. package/dist/scanner.d.ts +2 -2
  56. package/dist/scanner.d.ts.map +1 -1
  57. package/dist/scanner.js +76 -43
  58. package/dist/scanner.js.map +1 -1
  59. package/dist/scroll-listeners.d.ts +1 -1
  60. package/dist/scroll-listeners.d.ts.map +1 -1
  61. package/dist/scroll-listeners.js +3 -4
  62. package/dist/scroll-listeners.js.map +1 -1
  63. package/dist/state.d.ts +3 -2
  64. package/dist/state.d.ts.map +1 -1
  65. package/dist/state.js +5 -3
  66. package/dist/state.js.map +1 -1
  67. package/dist/task-queue.d.ts +4 -4
  68. package/dist/task-queue.d.ts.map +1 -1
  69. package/dist/task-queue.js +3 -2
  70. package/dist/task-queue.js.map +1 -1
  71. package/dist/types.d.ts +140 -49
  72. package/dist/types.d.ts.map +1 -1
  73. package/dist/types.js.map +1 -1
  74. package/dist/utils/are-elements-with-issues-equal.d.ts +3 -0
  75. package/dist/utils/are-elements-with-issues-equal.d.ts.map +1 -0
  76. package/dist/utils/are-elements-with-issues-equal.js +5 -0
  77. package/dist/utils/are-elements-with-issues-equal.js.map +1 -0
  78. package/dist/utils/are-issue-sets-equal.d.ts +2 -2
  79. package/dist/utils/are-issue-sets-equal.d.ts.map +1 -1
  80. package/dist/utils/are-issue-sets-equal.js +3 -3
  81. package/dist/utils/are-issue-sets-equal.js.map +1 -1
  82. package/dist/utils/containing-blocks.d.ts +3 -0
  83. package/dist/utils/containing-blocks.d.ts.map +1 -0
  84. package/dist/utils/containing-blocks.js +46 -0
  85. package/dist/utils/containing-blocks.js.map +1 -0
  86. package/dist/utils/contains.d.ts +2 -0
  87. package/dist/utils/contains.d.ts.map +1 -0
  88. package/dist/utils/contains.js +19 -0
  89. package/dist/utils/contains.js.map +1 -0
  90. package/dist/utils/deduplicate-nodes.d.ts +2 -0
  91. package/dist/utils/deduplicate-nodes.d.ts.map +1 -0
  92. package/dist/utils/deduplicate-nodes.js +4 -0
  93. package/dist/utils/deduplicate-nodes.js.map +1 -0
  94. package/dist/utils/deep-merge.d.ts +1 -1
  95. package/dist/utils/deep-merge.d.ts.map +1 -1
  96. package/dist/utils/deep-merge.js +8 -5
  97. package/dist/utils/deep-merge.js.map +1 -1
  98. package/dist/utils/dom-helpers.d.ts +9 -0
  99. package/dist/utils/dom-helpers.d.ts.map +1 -0
  100. package/dist/utils/dom-helpers.js +34 -0
  101. package/dist/utils/dom-helpers.js.map +1 -0
  102. package/dist/utils/ensure-non-empty.d.ts +2 -0
  103. package/dist/utils/ensure-non-empty.d.ts.map +1 -0
  104. package/dist/utils/ensure-non-empty.js +7 -0
  105. package/dist/utils/ensure-non-empty.js.map +1 -0
  106. package/dist/utils/get-element-html.d.ts +1 -1
  107. package/dist/utils/get-element-html.d.ts.map +1 -1
  108. package/dist/utils/get-element-html.js +4 -2
  109. package/dist/utils/get-element-html.js.map +1 -1
  110. package/dist/utils/get-element-position.d.ts +10 -2
  111. package/dist/utils/get-element-position.d.ts.map +1 -1
  112. package/dist/utils/get-element-position.js +64 -16
  113. package/dist/utils/get-element-position.js.map +1 -1
  114. package/dist/utils/get-parent.d.ts +2 -0
  115. package/dist/utils/get-parent.d.ts.map +1 -0
  116. package/dist/utils/get-parent.js +12 -0
  117. package/dist/utils/get-parent.js.map +1 -0
  118. package/dist/utils/get-scan-context.d.ts +3 -0
  119. package/dist/utils/get-scan-context.d.ts.map +1 -0
  120. package/dist/utils/get-scan-context.js +28 -0
  121. package/dist/utils/get-scan-context.js.map +1 -0
  122. package/dist/utils/get-scrollable-ancestors.d.ts +1 -1
  123. package/dist/utils/get-scrollable-ancestors.d.ts.map +1 -1
  124. package/dist/utils/get-scrollable-ancestors.js +10 -6
  125. package/dist/utils/get-scrollable-ancestors.js.map +1 -1
  126. package/dist/utils/is-node-in-scan-context.d.ts +3 -0
  127. package/dist/utils/is-node-in-scan-context.d.ts.map +1 -0
  128. package/dist/utils/is-node-in-scan-context.js +26 -0
  129. package/dist/utils/is-node-in-scan-context.js.map +1 -0
  130. package/dist/utils/is-non-empty.d.ts +2 -0
  131. package/dist/utils/is-non-empty.d.ts.map +1 -0
  132. package/dist/utils/is-non-empty.js +4 -0
  133. package/dist/utils/is-non-empty.js.map +1 -0
  134. package/dist/utils/normalize-context.d.ts +3 -0
  135. package/dist/utils/normalize-context.d.ts.map +1 -0
  136. package/dist/utils/normalize-context.js +59 -0
  137. package/dist/utils/normalize-context.js.map +1 -0
  138. package/dist/utils/recalculate-positions.d.ts +1 -1
  139. package/dist/utils/recalculate-positions.d.ts.map +1 -1
  140. package/dist/utils/recalculate-positions.js +5 -5
  141. package/dist/utils/recalculate-positions.js.map +1 -1
  142. package/dist/utils/recalculate-scrollable-ancestors.d.ts +1 -1
  143. package/dist/utils/recalculate-scrollable-ancestors.d.ts.map +1 -1
  144. package/dist/utils/recalculate-scrollable-ancestors.js +4 -4
  145. package/dist/utils/recalculate-scrollable-ancestors.js.map +1 -1
  146. package/dist/utils/shadow-dom-aware-mutation-observer.d.ts +10 -0
  147. package/dist/utils/shadow-dom-aware-mutation-observer.d.ts.map +1 -0
  148. package/dist/utils/shadow-dom-aware-mutation-observer.js +61 -0
  149. package/dist/utils/shadow-dom-aware-mutation-observer.js.map +1 -0
  150. package/dist/utils/supports-anchor-positioning.d.ts +1 -1
  151. package/dist/utils/supports-anchor-positioning.d.ts.map +1 -1
  152. package/dist/utils/supports-anchor-positioning.js +15 -2
  153. package/dist/utils/supports-anchor-positioning.js.map +1 -1
  154. package/dist/utils/transform-violations.d.ts +2 -2
  155. package/dist/utils/transform-violations.d.ts.map +1 -1
  156. package/dist/utils/transform-violations.js +25 -10
  157. package/dist/utils/transform-violations.js.map +1 -1
  158. package/dist/utils/update-elements-with-issues.d.ts +11 -5
  159. package/dist/utils/update-elements-with-issues.d.ts.map +1 -1
  160. package/dist/utils/update-elements-with-issues.js +56 -24
  161. package/dist/utils/update-elements-with-issues.js.map +1 -1
  162. package/dist/validate-options.d.ts +2 -2
  163. package/dist/validate-options.d.ts.map +1 -1
  164. package/dist/validate-options.js +91 -4
  165. package/dist/validate-options.js.map +1 -1
  166. package/package.json +16 -8
  167. package/src/accented.test.ts +2 -2
  168. package/src/accented.ts +45 -34
  169. package/src/common/strings.ts +2 -0
  170. package/src/common/tokens.ts +10 -0
  171. package/src/constants.ts +2 -1
  172. package/src/dom-updater.ts +87 -34
  173. package/src/elements/accented-dialog.ts +163 -123
  174. package/src/elements/accented-trigger.ts +128 -50
  175. package/src/fullscreen-listener.ts +21 -0
  176. package/src/intersection-observer.ts +27 -16
  177. package/src/log-and-rethrow.ts +2 -3
  178. package/src/logger.ts +14 -4
  179. package/src/register-elements.ts +7 -7
  180. package/src/resize-listener.ts +15 -11
  181. package/src/scanner.ts +113 -57
  182. package/src/scroll-listeners.ts +27 -19
  183. package/src/state.ts +27 -16
  184. package/src/task-queue.test.ts +5 -4
  185. package/src/task-queue.ts +8 -6
  186. package/src/types.ts +179 -76
  187. package/src/utils/are-elements-with-issues-equal.ts +11 -0
  188. package/src/utils/are-issue-sets-equal.test.ts +6 -7
  189. package/src/utils/are-issue-sets-equal.ts +8 -6
  190. package/src/utils/containing-blocks.ts +60 -0
  191. package/src/utils/contains.test.ts +54 -0
  192. package/src/utils/contains.ts +19 -0
  193. package/src/utils/deduplicate-nodes.ts +3 -0
  194. package/src/utils/deep-merge.test.ts +8 -1
  195. package/src/utils/deep-merge.ts +14 -8
  196. package/src/utils/dom-helpers.ts +42 -0
  197. package/src/utils/ensure-non-empty.ts +6 -0
  198. package/src/utils/get-element-html.ts +4 -2
  199. package/src/utils/get-element-position.ts +84 -16
  200. package/src/utils/get-parent.ts +14 -0
  201. package/src/utils/get-scan-context.test.ts +85 -0
  202. package/src/utils/get-scan-context.ts +36 -0
  203. package/src/utils/get-scrollable-ancestors.ts +15 -7
  204. package/src/utils/is-node-in-scan-context.test.ts +70 -0
  205. package/src/utils/is-node-in-scan-context.ts +29 -0
  206. package/src/utils/is-non-empty.ts +3 -0
  207. package/src/utils/normalize-context.test.ts +105 -0
  208. package/src/utils/normalize-context.ts +65 -0
  209. package/src/utils/recalculate-positions.ts +5 -5
  210. package/src/utils/recalculate-scrollable-ancestors.ts +4 -4
  211. package/src/utils/shadow-dom-aware-mutation-observer.ts +75 -0
  212. package/src/utils/supports-anchor-positioning.ts +19 -3
  213. package/src/utils/transform-violations.test.ts +29 -25
  214. package/src/utils/transform-violations.ts +32 -12
  215. package/src/utils/update-elements-with-issues.test.ts +145 -53
  216. package/src/utils/update-elements-with-issues.ts +123 -54
  217. package/src/validate-options.ts +154 -14
package/dist/scanner.js CHANGED
@@ -1,16 +1,18 @@
1
1
  import axe from 'axe-core';
2
- import TaskQueue from './task-queue.js';
2
+ import { getAccentedElementNames, issuesUrl } from './constants.js';
3
+ import { logAndRethrow } from './log-and-rethrow.js';
3
4
  import { elementsWithIssues, enabled, extendedElementsWithIssues } from './state.js';
4
- import updateElementsWithIssues from './utils/update-elements-with-issues.js';
5
- import recalculatePositions from './utils/recalculate-positions.js';
6
- import recalculateScrollableAncestors from './utils/recalculate-scrollable-ancestors.js';
7
- import supportsAnchorPositioning from './utils/supports-anchor-positioning.js';
8
- import { issuesUrl } from './constants.js';
9
- import logAndRethrow from './log-and-rethrow.js';
10
- export default function createScanner(name, axeContext, axeOptions, throttle, callback) {
5
+ import { TaskQueue } from './task-queue.js';
6
+ import { getScanContext } from './utils/get-scan-context.js';
7
+ import { recalculatePositions } from './utils/recalculate-positions.js';
8
+ import { recalculateScrollableAncestors } from './utils/recalculate-scrollable-ancestors.js';
9
+ import { createShadowDOMAwareMutationObserver } from './utils/shadow-dom-aware-mutation-observer.js';
10
+ import { supportsAnchorPositioning } from './utils/supports-anchor-positioning.js';
11
+ import { updateElementsWithIssues } from './utils/update-elements-with-issues.js';
12
+ export function createScanner(name, context, axeOptions, throttle, callback) {
11
13
  const axeRunningWindowProp = `__${name}_axe_running__`;
12
14
  const win = window;
13
- const taskQueue = new TaskQueue(async () => {
15
+ const taskQueue = new TaskQueue(async (nodes) => {
14
16
  // We may see errors coming from axe-core when Accented is toggled off and on in qiuck succession,
15
17
  // which I've seen happen with hot reloading of a React application.
16
18
  // This window property serves as a circuit breaker for that particular case.
@@ -18,40 +20,75 @@ export default function createScanner(name, axeContext, axeOptions, throttle, ca
18
20
  return;
19
21
  }
20
22
  try {
21
- performance.mark('axe-start');
23
+ performance.mark('scan-start');
22
24
  win[axeRunningWindowProp] = true;
25
+ const scanContext = getScanContext(nodes, context);
23
26
  let result;
24
27
  try {
25
- // TODO (https://github.com/pomerantsev/accented/issues/102):
26
- // only run Axe on what's changed, not on the whole axeContext
27
- result = await axe.run(axeContext, {
28
+ result = await axe.run(scanContext, {
29
+ /**
30
+ * By default, axe-core doesn't include element refs
31
+ * in the violations array,
32
+ * and we need those element refs.
33
+ */
28
34
  elementRef: true,
29
- // Although axe-core can perform iframe scanning, I haven't succeeded in it,
30
- // and the docs suggest that the axe-core script should be explicitly included
31
- // in each of the iframed documents anyway.
32
- // It seems preferable to disallow iframe scanning and not report issues in elements within iframes
33
- // in the case that such issues are for some reason reported by axe-core.
34
- // A consumer of Accented can instead scan the iframed document by calling Accented initialization from that document.
35
+ /**
36
+ * Although axe-core can perform iframe scanning, I haven't succeeded in it,
37
+ * and the docs suggest that the axe-core script should be explicitly included
38
+ * in each of the iframed documents anyway.
39
+ * It seems preferable to disallow iframe scanning and not report issues in elements within iframes
40
+ * in the case that such issues are for some reason reported by axe-core.
41
+ * A consumer of Accented can instead scan the iframed document by calling Accented initialization from that document.
42
+ */
35
43
  iframes: false,
44
+ /**
45
+ * The `preload` docs are not clear to me,
46
+ * but when it's set to `true` by default,
47
+ * axe-core tries to fetch cross-origin CSS,
48
+ * which fails in the absence of CORS headers.
49
+ * I'm not sure why axe-core needs to preload
50
+ * those resources in the first place,
51
+ * so disabling it seems to be the safe option.
52
+ */
53
+ preload: false,
54
+ /**
55
+ * We're only interested in violations,
56
+ * not in passes or incomplete results.
57
+ */
36
58
  resultTypes: ['violations'],
37
- ...axeOptions
59
+ ...axeOptions,
38
60
  });
39
61
  }
40
62
  catch (error) {
41
- console.error('Accented: axe-core (the accessibility testing engine) threw an error. ' +
42
- 'Check the `axeOptions` property that you’re passing to Accented. ' +
43
- `If you still think it’s a bug in Accented, file an issue at ${issuesUrl}.\n`, error);
44
- result = { violations: [] };
63
+ console.error(`Accented: axe-core (the accessibility testing engine) threw an error. Check the \`axeOptions\` property (https://accented.dev/api#axeoptions) that you’re passing to Accented. If you still think it’s a bug in Accented, file an issue at ${issuesUrl}.\n`, error);
45
64
  }
46
65
  win[axeRunningWindowProp] = false;
47
- const axeMeasure = performance.measure('axe', 'axe-start');
48
- if (!enabled.value) {
66
+ const scanMeasure = performance.measure('scan', 'scan-start');
67
+ const scanDuration = Math.round(scanMeasure.duration);
68
+ if (!enabled.value || !result) {
49
69
  return;
50
70
  }
51
- updateElementsWithIssues(extendedElementsWithIssues, result.violations, window, name);
71
+ performance.mark('dom-update-start');
72
+ updateElementsWithIssues({
73
+ extendedElementsWithIssues,
74
+ scanContext,
75
+ violations: result.violations,
76
+ win: window,
77
+ name,
78
+ });
79
+ const domUpdateMeasure = performance.measure('dom-update', 'dom-update-start');
80
+ const domUpdateDuration = Math.round(domUpdateMeasure.duration);
52
81
  callback({
82
+ // Assuming that the {include, exclude} shape of the context object will be used less often
83
+ // than other variants, we'll output just the `include` array in case nothing is excluded
84
+ // in the scan.
85
+ scanContext: scanContext.exclude.length > 0 ? scanContext : scanContext.include,
53
86
  elementsWithIssues: elementsWithIssues.value,
54
- scanDuration: Math.round(axeMeasure.duration)
87
+ performance: {
88
+ totalBlockingTime: scanDuration + domUpdateDuration,
89
+ scan: scanDuration,
90
+ domUpdate: domUpdateDuration,
91
+ },
55
92
  });
56
93
  }
57
94
  catch (error) {
@@ -59,19 +96,16 @@ export default function createScanner(name, axeContext, axeOptions, throttle, ca
59
96
  logAndRethrow(error);
60
97
  }
61
98
  }, throttle);
62
- // TODO (https://github.com/pomerantsev/accented/issues/102):
63
- // limit to what's in axeContext,
64
- // if that's an element or array of elements (not a selector).
65
99
  taskQueue.add(document);
66
- const accentedElementNames = [`${name}-trigger`, `${name}-dialog`];
67
- const mutationObserver = new MutationObserver(mutationList => {
100
+ const accentedElementNames = getAccentedElementNames(name);
101
+ const mutationObserver = createShadowDOMAwareMutationObserver(name, (mutationList) => {
68
102
  try {
69
103
  // We're not interested in mutations that are caused exclusively by the custom elements
70
104
  // introduced by Accented.
71
- const listWithoutAccentedElements = mutationList.filter(mutationRecord => {
105
+ const listWithoutAccentedElements = mutationList.filter((mutationRecord) => {
72
106
  const onlyAccentedElementsAddedOrRemoved = mutationRecord.type === 'childList' &&
73
- [...mutationRecord.addedNodes].every(node => accentedElementNames.includes(node.nodeName.toLowerCase())) &&
74
- [...mutationRecord.removedNodes].every(node => accentedElementNames.includes(node.nodeName.toLowerCase()));
107
+ [...mutationRecord.addedNodes].every((node) => accentedElementNames.includes(node.nodeName.toLowerCase())) &&
108
+ [...mutationRecord.removedNodes].every((node) => accentedElementNames.includes(node.nodeName.toLowerCase()));
75
109
  const accentedElementChanged = mutationRecord.type === 'attributes' &&
76
110
  accentedElementNames.includes(mutationRecord.target.nodeName.toLowerCase());
77
111
  return !(onlyAccentedElementsAddedOrRemoved || accentedElementChanged);
@@ -90,28 +124,27 @@ export default function createScanner(name, axeContext, axeOptions, throttle, ca
90
124
  // we may miss other mutations on those same elements caused by Accented,
91
125
  // leading to extra runs of the mutation observer.
92
126
  const elementsWithAccentedAttributeChanges = listWithoutAccentedElements.reduce((nodes, mutationRecord) => {
93
- if (mutationRecord.type === 'attributes' && mutationRecord.attributeName === `data-${name}`) {
127
+ if (mutationRecord.type === 'attributes' &&
128
+ mutationRecord.attributeName === `data-${name}`) {
94
129
  nodes.add(mutationRecord.target);
95
130
  }
96
131
  return nodes;
97
132
  }, new Set());
98
- const filteredMutationList = listWithoutAccentedElements.filter(mutationRecord => {
133
+ const filteredMutationList = listWithoutAccentedElements.filter((mutationRecord) => {
99
134
  return !elementsWithAccentedAttributeChanges.has(mutationRecord.target);
100
135
  });
101
- taskQueue.addMultiple(filteredMutationList.map(mutationRecord => mutationRecord.target));
136
+ const nodes = filteredMutationList.map((mutationRecord) => mutationRecord.target);
137
+ taskQueue.addMultiple(nodes);
102
138
  }
103
139
  catch (error) {
104
140
  logAndRethrow(error);
105
141
  }
106
142
  });
107
- // TODO (https://github.com/pomerantsev/accented/issues/102):
108
- // possibly limit the observer to what's in axeContext,
109
- // if that's an element or array of elements (not a selector).
110
143
  mutationObserver.observe(document, {
111
144
  subtree: true,
112
145
  childList: true,
113
146
  attributes: true,
114
- characterData: true
147
+ characterData: true,
115
148
  });
116
149
  return () => {
117
150
  mutationObserver.disconnect();
@@ -1 +1 @@
1
- {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAErF,OAAO,wBAAwB,MAAM,wCAAwC,CAAC;AAC9E,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,8BAA8B,MAAM,6CAA6C,CAAC;AACzF,OAAO,yBAAyB,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,gBA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jF,OAAO,CAAC,oCAAoC,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YAC1E,CAAC,CAAC,CAAC;YAEH,MAAM,KAAK,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YAClF,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,gBAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE;QACjC,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,gBAAgB,CAAC,UAAU,EAAE,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC"}
@@ -1,2 +1,2 @@
1
- export default function setupScrollListeners(): () => void;
1
+ export declare function setupScrollListeners(): () => void;
2
2
  //# sourceMappingURL=scroll-listeners.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-listeners.d.ts","sourceRoot":"","sources":["../src/scroll-listeners.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,oBAAoB,eA+B3C"}
1
+ {"version":3,"file":"scroll-listeners.d.ts","sourceRoot":"","sources":["../src/scroll-listeners.ts"],"names":[],"mappings":"AAKA,wBAAgB,oBAAoB,eAuCnC"}
@@ -1,8 +1,8 @@
1
1
  import { effect } from '@preact/signals-core';
2
- import recalculatePositions from './utils/recalculate-positions.js';
2
+ import { logAndRethrow } from './log-and-rethrow.js';
3
3
  import { scrollableAncestors } from './state.js';
4
- import logAndRethrow from './log-and-rethrow.js';
5
- export default function setupScrollListeners() {
4
+ import { recalculatePositions } from './utils/recalculate-positions.js';
5
+ export function setupScrollListeners() {
6
6
  const documentAbortController = new AbortController();
7
7
  document.addEventListener('scroll', () => {
8
8
  try {
@@ -34,5 +34,4 @@ export default function setupScrollListeners() {
34
34
  disposeOfEffect();
35
35
  };
36
36
  }
37
- ;
38
37
  //# sourceMappingURL=scroll-listeners.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-listeners.js","sourceRoot":"","sources":["../src/scroll-listeners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAEjD,MAAM,CAAC,OAAO,UAAU,oBAAoB;IAC1C,MAAM,uBAAuB,GAAG,IAAI,eAAe,EAAE,CAAC;IACtD,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,EAAE;QACvC,IAAI,CAAC;YACH,oBAAoB,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAuB,CAAC,MAAM,EAAE,CAAC,CAAC;IAE/C,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,EAAE;QAClC,wCAAwC;QACxC,MAAM,sBAAsB,GAAG,IAAI,eAAe,EAAE,CAAC;QACrD,KAAK,MAAM,kBAAkB,IAAI,mBAAmB,CAAC,KAAK,EAAE,CAAC;YAC3D,kBAAkB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,EAAE;gBACjD,IAAI,CAAC;oBACH,oBAAoB,EAAE,CAAC;gBACzB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,aAAa,CAAC,KAAK,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC,EAAE,EAAE,MAAM,EAAE,sBAAsB,CAAC,MAAM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K,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC,EACD,EAAE,MAAM,EAAE,sBAAsB,CAAC,MAAM,EAAE,CAC1C,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,EAAE;YACV,sBAAsB,CAAC,KAAK,EAAE,CAAC;QACjC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,uBAAuB,CAAC,KAAK,EAAE,CAAC;QAChC,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
package/dist/state.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import type { ElementWithIssues, ExtendedElementWithIssues } from './types';
1
+ import type { ElementWithIssues, ExtendedElementWithIssues } from './types.ts';
2
2
  export declare const enabled: import("@preact/signals-core").Signal<boolean>;
3
3
  export declare const extendedElementsWithIssues: import("@preact/signals-core").Signal<ExtendedElementWithIssues[]>;
4
4
  export declare const elementsWithIssues: import("@preact/signals-core").ReadonlySignal<ElementWithIssues[]>;
5
- export declare const scrollableAncestors: import("@preact/signals-core").ReadonlySignal<Set<HTMLElement>>;
5
+ export declare const rootNodes: import("@preact/signals-core").ReadonlySignal<Set<Node>>;
6
+ export declare const scrollableAncestors: import("@preact/signals-core").ReadonlySignal<Set<Element>>;
6
7
  //# sourceMappingURL=state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAE5E,eAAO,MAAM,OAAO,gDAAgB,CAAC;AAErC,eAAO,MAAM,0BAA0B,oEAA+C,CAAC;AAEvF,eAAO,MAAM,kBAAkB,oEAG3B,CAAC;AAEL,eAAO,MAAM,mBAAmB,iEAU/B,CAAC"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE/E,eAAO,MAAM,OAAO,gDAAgB,CAAC;AAErC,eAAO,MAAM,0BAA0B,oEAA+C,CAAC;AAEvF,eAAO,MAAM,kBAAkB,oEAM9B,CAAC;AAEF,eAAO,MAAM,SAAS,0DASrB,CAAC;AAEF,eAAO,MAAM,mBAAmB,6DAO/B,CAAC"}
package/dist/state.js CHANGED
@@ -1,10 +1,12 @@
1
- import { signal, computed } from '@preact/signals-core';
1
+ import { computed, signal } from '@preact/signals-core';
2
2
  export const enabled = signal(false);
3
3
  export const extendedElementsWithIssues = signal([]);
4
- export const elementsWithIssues = computed(() => extendedElementsWithIssues.value.map(extendedElementWithIssues => ({
4
+ export const elementsWithIssues = computed(() => extendedElementsWithIssues.value.map((extendedElementWithIssues) => ({
5
5
  element: extendedElementWithIssues.element,
6
- issues: extendedElementWithIssues.issues.value
6
+ rootNode: extendedElementWithIssues.rootNode,
7
+ issues: extendedElementWithIssues.issues.value,
7
8
  })));
9
+ export const rootNodes = computed(() => new Set((enabled.value ? [document] : []).concat(...extendedElementsWithIssues.value.map((extendedElementWithIssues) => extendedElementWithIssues.rootNode))));
8
10
  export const scrollableAncestors = computed(() => extendedElementsWithIssues.value.reduce((scrollableAncestors, extendedElementWithIssues) => {
9
11
  for (const scrollableAncestor of extendedElementWithIssues.scrollableAncestors.value) {
10
12
  scrollableAncestors.add(scrollableAncestor);
package/dist/state.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIxD,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAErC,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAmC,EAAE,CAAC,CAAC;AAEvF,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAA2B,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AAI,GAAG,CACL,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAC9C,GAAG,0BAA0B,CAAC,KAAK,CAAC,GAAG,CACrC,CAAC,yBAAyB,EAAE,EAAE,CAAC,yBAAyB,CAAC,QAAQ,CAClE,CACF,CACF,CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAe,GAAG,EAAE,CAC7D,0BAA0B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,mBAAmB,EAAE,yBAAyB,EAAE,EAAE;IACzF,KAAK,MAAM,kBAAkB,IAAI,yBAAyB,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACrF,mBAAmB,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC,EAAE,IAAI,GAAG,EAAW,CAAC,CACvB,CAAC"}
@@ -1,8 +1,8 @@
1
- import type { Throttle } from './types';
2
- type TaskCallback = () => void;
3
- export default class TaskQueue<T> {
1
+ import type { Throttle } from './types.ts';
2
+ type TaskCallback<T> = (items: Array<T>) => void;
3
+ export declare class TaskQueue<T> {
4
4
  #private;
5
- constructor(asyncCallback: TaskCallback, throttle: Required<Throttle>);
5
+ constructor(asyncCallback: TaskCallback<T>, throttle: Required<Throttle>);
6
6
  addMultiple(items: Array<T>): void;
7
7
  add(item: T): void;
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"task-queue.d.ts","sourceRoot":"","sources":["../src/task-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,KAAK,YAAY,GAAG,MAAM,IAAI,CAAC;AAE/B,MAAM,CAAC,OAAO,OAAO,SAAS,CAAC,CAAC;;gBAOlB,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAmCrE,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAS3B,GAAG,CAAC,IAAI,EAAE,CAAC;CAGZ"}
1
+ {"version":3,"file":"task-queue.d.ts","sourceRoot":"","sources":["../src/task-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAEjD,qBAAa,SAAS,CAAC,CAAC;;gBAOV,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAqCxE,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAS3B,GAAG,CAAC,IAAI,EAAE,CAAC;CAGZ"}
@@ -1,4 +1,4 @@
1
- export default class TaskQueue {
1
+ export class TaskQueue {
2
2
  #throttle;
3
3
  #asyncCallback = null;
4
4
  #items = new Set();
@@ -22,9 +22,10 @@ export default class TaskQueue {
22
22
  this.#inRunLoop = false;
23
23
  return;
24
24
  }
25
+ const items = Array.from(this.#items);
25
26
  this.#items.clear();
26
27
  if (this.#asyncCallback) {
27
- await this.#asyncCallback();
28
+ await this.#asyncCallback(items);
28
29
  }
29
30
  await new Promise((resolve) => setTimeout(resolve, this.#throttle.wait));
30
31
  await this.#run();
@@ -1 +1 @@
1
- {"version":3,"file":"task-queue.js","sourceRoot":"","sources":["../src/task-queue.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,SAAS,CAAW;IACpB,cAAc,GAAwB,IAAI,CAAC;IAE3C,MAAM,GAAG,IAAI,GAAG,EAAK,CAAC;IACtB,UAAU,GAAG,KAAK,CAAC;IAEnB,YAAY,aAA2B,EAAE,QAA4B;QACnE,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QAC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,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAEzE,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;IAED,WAAW,CAAC,KAAe;QACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAED,GAAG,CAAC,IAAO;QACT,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3B,CAAC;CACF"}
package/dist/types.d.ts CHANGED
@@ -1,62 +1,84 @@
1
- import type axe from 'axe-core';
2
1
  import type { Signal } from '@preact/signals-core';
3
- import type { AccentedTrigger } from './elements/accented-trigger';
2
+ import type axe from 'axe-core';
3
+ import type { AccentedTrigger } from './elements/accented-trigger.ts';
4
4
  export type Throttle = {
5
5
  /**
6
- * The minimal time between scans.
6
+ * How long Accented must wait (in milliseconds) to run a scan after a mutation or after the previous scan (whichever finished last).
7
+ *
8
+ * If the page you’re scanning has a lot of nodes,
9
+ * scanning may take a noticeable time (~ a few hundred milliseconds),
10
+ * during which time the main thread will be blocked most of the time.
7
11
  *
8
- * Default: `1000`.
12
+ * You may want to experiment with this value if your page contents change frequently
13
+ * or if it has JavaScript-based animations running on the main thread.
14
+ *
15
+ * @default 1000
9
16
  * */
10
17
  wait?: number;
11
18
  /**
12
- * When to run the scan on Accented initialization or on a mutation.
19
+ * If `leading` is set to `true`, the scan runs immediately after a mutation.
20
+ * In this case, `wait` only applies to subsequent scans,
21
+ * giving the page at least `wait` milliseconds between the end of the previous scan
22
+ * and the beginning of the next one.
13
23
  *
14
- * If `true`, the scan will run immediately. If `false`, the scan will run after the first throttle delay.
24
+ * If `leading` is set to `false`, the wait applies to mutations as well,
25
+ * delaying the output.
26
+ * This may be useful if you’re expecting quick bursts of mutations on your page.
15
27
  *
16
- * Default: `true`.
28
+ * @default true
17
29
  * */
18
30
  leading?: boolean;
19
31
  };
20
32
  export type Output = {
21
33
  /**
22
- * Whether to output the issues to the console.
34
+ * Whether the list of elements with issues should be printed to the browser console whenever issues are added, removed, or changed.
23
35
  *
24
- * Default: `true`.
36
+ * @default true
25
37
  * */
26
38
  console?: boolean;
27
39
  };
28
- export type AxeContext = axe.ElementContext;
40
+ /**
41
+ * Model context type based on axe.ElementContext,
42
+ * excluding frame selectors (since we don't support scanning iframes).
43
+ */
44
+ export type Selector = Exclude<axe.Selector, axe.LabelledFramesSelector>;
45
+ export type SelectorList = Array<Selector> | NodeList;
46
+ export type ContextProp = Selector | SelectorList;
47
+ export type ContextObject = {
48
+ include: ContextProp;
49
+ exclude?: ContextProp;
50
+ } | {
51
+ exclude: ContextProp;
52
+ include?: ContextProp;
53
+ };
54
+ export type Context = ContextProp | ContextObject;
29
55
  export declare const allowedAxeOptions: readonly ["rules", "runOnly"];
30
- export type AxeOptions = Pick<axe.RunOptions, typeof allowedAxeOptions[number]>;
56
+ export type AxeOptions = Pick<axe.RunOptions, (typeof allowedAxeOptions)[number]>;
31
57
  type CallbackParams = {
32
58
  /**
33
- * The most current array of elements with issues.
59
+ * The most up-to-date array of all elements with accessibility issues.
34
60
  * */
35
61
  elementsWithIssues: Array<ElementWithIssues>;
36
62
  /**
37
- * How long the scan took in milliseconds.
63
+ * Runtime performance of the last scan. An object with the following props:
64
+ * - `totalBlockingTime`: how long the main thread was blocked by Accented during the last scan, in milliseconds.
65
+ * It’s further divided into the `scan` and `domUpdate` phases.
66
+ * - `scan`: how long scanning (the execution of `axe.run()`) took, in milliseconds.
67
+ * - `domUpdate`: how long the DOM update (adding / removing outlines and dialog trigger buttons) took, in milliseconds.
38
68
  * */
39
- scanDuration: number;
69
+ performance: {
70
+ totalBlockingTime: number;
71
+ scan: number;
72
+ domUpdate: number;
73
+ };
74
+ /**
75
+ * Nodes that got scanned. Either an array of nodes,
76
+ * or an object with `include` and `exclude` properties (if any nodes were excluded).
77
+ */
78
+ scanContext: ScanContext | Array<Node>;
40
79
  };
41
80
  export type Callback = (params: CallbackParams) => void;
42
81
  export type AccentedOptions = {
43
- /**
44
- * The `context` parameter for `axe.run()`.
45
- *
46
- * Determines what element(s) to scan for accessibility issues.
47
- *
48
- * Accepts a variety of shapes:
49
- * * an element reference;
50
- * * a selector;
51
- * * a `NodeList`;
52
- * * an include / exclude object;
53
- * * and more.
54
- *
55
- * See documentation: https://www.deque.com/axe/core-documentation/api-documentation/#context-parameter
56
- *
57
- * Default: `document`.
58
- */
59
- axeContext?: AxeContext;
60
82
  /**
61
83
  * The `options` parameter for `axe.run()`.
62
84
  *
@@ -69,13 +91,70 @@ export type AccentedOptions = {
69
91
  *
70
92
  * See documentation: https://www.deque.com/axe/core-documentation/api-documentation/#options-parameter
71
93
  *
72
- * Default: `{}`.
94
+ * @default {}
73
95
  */
74
96
  axeOptions?: AxeOptions;
97
+ /**
98
+ * A function that will be called after each scan.
99
+ *
100
+ * Potential uses:
101
+
102
+ * - do something with the scan results,
103
+ * for example send them to a backend for storage and analysis;
104
+ * - analyze Accented’s performance.
105
+ *
106
+ * @default () => {}
107
+ *
108
+ * @example
109
+ *
110
+ * accented({
111
+ * callback: ({ elementsWithIssues, performance, scanContext }) => {
112
+ * console.log('Elements with issues:', elementsWithIssues);
113
+ * console.log('Total blocking time:', performance.totalBlockingTime);
114
+ * console.log('Scan context:', scanContext);
115
+ * }
116
+ * });
117
+ *
118
+ * */
119
+ callback?: Callback;
120
+ /**
121
+ * The `context` parameter for `axe.run()`.
122
+ *
123
+ * Determines what part(s) of the page to scan for accessibility issues.
124
+ *
125
+ * Accepts a variety of shapes:
126
+ *
127
+ * - a [`Node`](https://developer.mozilla.org/en-US/docs/Web/API/Node) (in practice it will likely be an instance of [`Element`](https://developer.mozilla.org/en-US/docs/Web/API/Element), [`Document`](https://developer.mozilla.org/en-US/docs/Web/API/Document), or [`DocumentFragment`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment));
128
+ * - a valid [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors);
129
+ * - an object for selecting elements within shadow DOM,
130
+ * whose shape is `{ fromShadowDom: [selector1, selector2, ...] }`,
131
+ * where `selector1`, `selector2`, etc. select shadow hosts, and the last selector selects the actual context.
132
+ * `selector2` in this example is _within_ the shadow root created on the element(s) that match `selector1`,
133
+ * so in practice you shouldn’t have more than two elements in such an array
134
+ * unless you have a very complex structure with multiple shadow DOM layers;
135
+ * - a [`NodeList`](https://developer.mozilla.org/en-US/docs/Web/API/NodeList) (likely a result of a [`querySelectorAll()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll) call);
136
+ * - an array containing any combination of selectors, nodes, or shadow DOM objects (described above);
137
+ * - an object containing `include` and / or `exclude` properties.
138
+ * It’s useful if you’d like to exclude certain elements or parts of the page.
139
+ * The values for `include` and `exclude` can take any of the above shapes.
140
+ * It’s unlikely that you’d want to have complex `include` / `exclude` rules,
141
+ * but if you do, the exact behavior is documented by the relevant tests:
142
+ * [`is-node-in-scan-context.test.ts`](https://github.com/pomerantsev/accented/blob/main/packages/accented/src/utils/is-node-in-scan-context.test.ts).
143
+ *
144
+ * See also the documentation for the [`context` parameter of `axe.run()`](https://www.deque.com/axe/core-documentation/api-documentation/#context-parameter),
145
+ * which the `context` option from Accented mostly mirrors
146
+ * (note that Accented doesn’t support the `fromFrames` object shape).
147
+ *
148
+ * @default document
149
+ */
150
+ context?: Context;
75
151
  /**
76
152
  * The character sequence that’s used in various elements, attributes and stylesheets that Accented adds to the page.
153
+ *
154
+ * You shouldn’t have to provide this prop unless some of the names on your page have "accented" in it and conflict with what Accented provides by default.
155
+ *
77
156
  * * The data attribute that’s added to elements with issues (default: `data-accented`).
78
- * * The custom elements for the button and the dialog that get created for each element with issues
157
+ * * The names of custom elements for the button and the dialog that get created for each element with issues
79
158
  * (default: `accented-trigger`, `accented-dialog`).
80
159
  * * The CSS cascade layer containing page-wide Accented-specific styles (default: `accented`).
81
160
  * * The prefix for some of the CSS custom properties used by Accented (default: `--accented-`).
@@ -85,23 +164,25 @@ export type AccentedOptions = {
85
164
  * Only lowercase alphanumeric characters and dashes (-) are allowed in the name,
86
165
  * and it must start with a lowercase letter.
87
166
  *
88
- * Default: `accented`.
167
+ * @default 'accented'
168
+ *
169
+ * @example
170
+ *
171
+ * accented({name: 'my-name'});
172
+ *
173
+ * With the above option provided, the attribute set on elements with issues will be `data-my-name`,
174
+ * a custom element will be called `my-name-trigger`, and so on.
175
+ *
89
176
  */
90
177
  name?: string;
91
178
  /**
92
- * Output options object.
179
+ * An object controlling how the results of scans are presented.
93
180
  * */
94
181
  output?: Output;
95
182
  /**
96
- * Scan throttling options object.
183
+ * An object controlling at what moments Accented will run its scans.
97
184
  * */
98
185
  throttle?: Throttle;
99
- /**
100
- * A callback that will be called after each scan.
101
- *
102
- * Default: `() => {}`.
103
- * */
104
- callback?: Callback;
105
186
  };
106
187
  /**
107
188
  * A function that fully disables Accented,
@@ -109,9 +190,10 @@ export type AccentedOptions = {
109
190
  */
110
191
  export type DisableAccented = () => void;
111
192
  export type Position = {
112
- inlineEndLeft: number;
113
- blockStartTop: number;
114
- direction: 'ltr' | 'rtl';
193
+ left: number;
194
+ top: number;
195
+ width: number;
196
+ height: number;
115
197
  };
116
198
  export type Issue = {
117
199
  id: string;
@@ -120,17 +202,26 @@ export type Issue = {
120
202
  url: string;
121
203
  impact: axe.ImpactValue;
122
204
  };
123
- export type ElementWithIssues = {
124
- element: HTMLElement;
205
+ export type BaseElementWithIssues = {
206
+ element: HTMLElement | SVGElement;
207
+ rootNode: Node;
208
+ };
209
+ export type ElementWithIssues = BaseElementWithIssues & {
125
210
  issues: Array<Issue>;
126
211
  };
127
- export type ExtendedElementWithIssues = Omit<ElementWithIssues, 'issues'> & {
212
+ export type ExtendedElementWithIssues = BaseElementWithIssues & {
128
213
  issues: Signal<ElementWithIssues['issues']>;
129
214
  visible: Signal<boolean>;
130
215
  trigger: AccentedTrigger;
131
216
  position: Signal<Position>;
132
- scrollableAncestors: Signal<Set<HTMLElement>>;
217
+ skipRender: boolean;
218
+ anchorNameValue: string;
219
+ scrollableAncestors: Signal<Set<Element>>;
133
220
  id: number;
134
221
  };
222
+ export type ScanContext = {
223
+ include: Array<Node>;
224
+ exclude: Array<Node>;
225
+ };
135
226
  export {};
136
227
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,MAAM,QAAQ,GAAG;IACrB;;;;SAIK;IACL,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;SAMK;IACL,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG;IACnB;;;;SAIK;IACL,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,GAAG,CAAC,cAAc,CAAC;AAE5C,eAAO,MAAM,iBAAiB,+BAAgC,CAAC;AAE/D,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;AAEhF,KAAK,cAAc,GAAG;IACpB;;SAEK;IACL,kBAAkB,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAE7C;;SAEK;IACL,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,CAAC,MA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