accented 1.2.6 → 1.3.0

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 (31) hide show
  1. package/dist/constants.d.ts +12 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +32 -0
  4. package/dist/constants.js.map +1 -1
  5. package/dist/scanner.d.ts.map +1 -1
  6. package/dist/scanner.js +79 -41
  7. package/dist/scanner.js.map +1 -1
  8. package/dist/utils/create-extended-element-with-issues.d.ts +3 -0
  9. package/dist/utils/create-extended-element-with-issues.d.ts.map +1 -0
  10. package/dist/utils/create-extended-element-with-issues.js +56 -0
  11. package/dist/utils/create-extended-element-with-issues.js.map +1 -0
  12. package/dist/utils/get-all-rules-from-axe-options.d.ts +3 -0
  13. package/dist/utils/get-all-rules-from-axe-options.d.ts.map +1 -0
  14. package/dist/utils/get-all-rules-from-axe-options.js +51 -0
  15. package/dist/utils/get-all-rules-from-axe-options.js.map +1 -0
  16. package/dist/utils/transform-violations.d.ts.map +1 -1
  17. package/dist/utils/transform-violations.js +2 -13
  18. package/dist/utils/transform-violations.js.map +1 -1
  19. package/dist/utils/update-elements-with-issues.d.ts +4 -3
  20. package/dist/utils/update-elements-with-issues.d.ts.map +1 -1
  21. package/dist/utils/update-elements-with-issues.js +36 -80
  22. package/dist/utils/update-elements-with-issues.js.map +1 -1
  23. package/package.json +4 -4
  24. package/src/constants.ts +34 -0
  25. package/src/scanner.ts +91 -45
  26. package/src/utils/create-extended-element-with-issues.ts +67 -0
  27. package/src/utils/get-all-rules-from-axe-options.test.ts +169 -0
  28. package/src/utils/get-all-rules-from-axe-options.ts +54 -0
  29. package/src/utils/transform-violations.ts +2 -14
  30. package/src/utils/update-elements-with-issues.test.ts +223 -139
  31. package/src/utils/update-elements-with-issues.ts +76 -107
@@ -3,4 +3,16 @@ export declare const accentedUrl = "https://accented.dev";
3
3
  export declare const issuesUrl = "https://github.com/pomerantsev/accented/issues";
4
4
  export declare const getAccentedElementNames: (name: string) => string[];
5
5
  export declare const orderedImpacts: Array<Issue['impact']>;
6
+ /**
7
+ * axe-core rules whose pass/fail depends on the presence or absence of specific descendants
8
+ * (not just direct children). When any DOM mutation occurs, these rules must be re-evaluated
9
+ * against the full scan context, because the mutated node may be deep inside the element
10
+ * that the violation is reported on — and therefore outside the limited scan context.
11
+ */
12
+ export declare const descendantDependentRules: Set<string>;
13
+ /**
14
+ * axe-core violations (their ids) that may be flagged by axe-core
15
+ * as false positives if an Accented trigger is a descendant of the element with the issue.
16
+ */
17
+ export declare const violationsAffectedByAccentedTriggers: Set<string>;
6
18
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,WAAW,yBAAyB,CAAC;AAClD,eAAO,MAAM,SAAS,mDAAmD,CAAC;AAC1E,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,aAA0C,CAAC;AAE/F,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAgD,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,WAAW,yBAAyB,CAAC;AAClD,eAAO,MAAM,SAAS,mDAAmD,CAAC;AAC1E,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,aAA0C,CAAC;AAE/F,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAgD,CAAC;AAEnG;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,aAYnC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oCAAoC,aAQ/C,CAAC"}
package/dist/constants.js CHANGED
@@ -2,4 +2,36 @@ export const accentedUrl = 'https://accented.dev';
2
2
  export const issuesUrl = 'https://github.com/pomerantsev/accented/issues';
3
3
  export const getAccentedElementNames = (name) => [`${name}-trigger`, `${name}-dialog`];
4
4
  export const orderedImpacts = ['minor', 'moderate', 'serious', 'critical'];
5
+ /**
6
+ * axe-core rules whose pass/fail depends on the presence or absence of specific descendants
7
+ * (not just direct children). When any DOM mutation occurs, these rules must be re-evaluated
8
+ * against the full scan context, because the mutated node may be deep inside the element
9
+ * that the violation is reported on — and therefore outside the limited scan context.
10
+ */
11
+ export const descendantDependentRules = new Set([
12
+ 'aria-hidden-focus',
13
+ 'aria-required-children',
14
+ 'aria-text',
15
+ 'document-title',
16
+ 'landmark-no-duplicate-banner',
17
+ 'landmark-no-duplicate-contentinfo',
18
+ 'landmark-no-duplicate-main',
19
+ 'landmark-one-main',
20
+ 'nested-interactive',
21
+ 'page-has-heading-one',
22
+ 'scrollable-region-focusable',
23
+ ]);
24
+ /**
25
+ * axe-core violations (their ids) that may be flagged by axe-core
26
+ * as false positives if an Accented trigger is a descendant of the element with the issue.
27
+ */
28
+ export const violationsAffectedByAccentedTriggers = new Set([
29
+ 'aria-hidden-focus',
30
+ 'aria-text',
31
+ 'definition-list',
32
+ 'label-content-name-mismatch',
33
+ 'list',
34
+ 'nested-interactive',
35
+ 'scrollable-region-focusable', // The Accented trigger might make the content grow such that scrolling is required.
36
+ ]);
5
37
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAClD,MAAM,CAAC,MAAM,SAAS,GAAG,gDAAgD,CAAC;AAC1E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,UAAU,EAAE,GAAG,IAAI,SAAS,CAAC,CAAC;AAE/F,MAAM,CAAC,MAAM,cAAc,GAA2B,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAClD,MAAM,CAAC,MAAM,SAAS,GAAG,gDAAgD,CAAC;AAC1E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,UAAU,EAAE,GAAG,IAAI,SAAS,CAAC,CAAC;AAE/F,MAAM,CAAC,MAAM,cAAc,GAA2B,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAEnG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC;IAC9C,mBAAmB;IACnB,wBAAwB;IACxB,WAAW;IACX,gBAAgB;IAChB,8BAA8B;IAC9B,mCAAmC;IACnC,4BAA4B;IAC5B,mBAAmB;IACnB,oBAAoB;IACpB,sBAAsB;IACtB,6BAA6B;CAC9B,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,IAAI,GAAG,CAAC;IAC1D,mBAAmB;IACnB,WAAW;IACX,iBAAiB;IACjB,6BAA6B;IAC7B,MAAM;IACN,oBAAoB;IACpB,6BAA6B,EAAE,oFAAoF;CACpH,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAQ1E,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC5B,QAAQ,EAAE,QAAQ,cA+KnB"}
1
+ {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAS1E,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC5B,QAAQ,EAAE,QAAQ,cA4NnB"}
package/dist/scanner.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import axe from 'axe-core';
2
- import { getAccentedElementNames, issuesUrl } from './constants.js';
2
+ import { descendantDependentRules, getAccentedElementNames, issuesUrl } from './constants.js';
3
3
  import { logAndRethrow } from './log-and-rethrow.js';
4
4
  import { elementsWithIssues, enabled, extendedElementsWithIssues } from './state.js';
5
5
  import { TaskQueue } from './task-queue.js';
6
+ import { getAllRulesFromAxeOptions } from './utils/get-all-rules-from-axe-options.js';
6
7
  import { getScanContext } from './utils/get-scan-context.js';
7
8
  import { recalculatePositions } from './utils/recalculate-positions.js';
8
9
  import { recalculateScrollableAncestors } from './utils/recalculate-scrollable-ancestors.js';
@@ -10,10 +11,59 @@ import { createShadowDOMAwareMutationObserver } from './utils/shadow-dom-aware-m
10
11
  import { supportsAnchorPositioning } from './utils/supports-anchor-positioning.js';
11
12
  import { updateElementsWithIssues } from './utils/update-elements-with-issues.js';
12
13
  export function createScanner(name, context, axeOptions, throttle, callback) {
14
+ const allRules = getAllRulesFromAxeOptions(axeOptions);
15
+ /**
16
+ * Rules that only look at the element itself — safe to run
17
+ * against only the nodes affected by the current mutation.
18
+ */
19
+ const limitedContextRules = new Set([...allRules].filter((rule) => !descendantDependentRules.has(rule)));
20
+ /**
21
+ * Rules whose pass/fail depends on descendants anywhere in the subtree.
22
+ * A mutation deep inside an element can change the outcome for the ancestor,
23
+ * so these must always run against the full scan context.
24
+ */
25
+ const fullContextRules = new Set([...allRules].filter((rule) => descendantDependentRules.has(rule)));
26
+ /**
27
+ * Options shared by both axe.run() calls. The user's runOnly and rules are
28
+ * consumed by getAllRulesFromAxeOptions above and replaced by explicit rule
29
+ * sets, so they are not forwarded here.
30
+ */
31
+ const baseAxeOptions = {
32
+ /**
33
+ * By default, axe-core doesn't include element refs
34
+ * in the violations array,
35
+ * and we need those element refs.
36
+ */
37
+ elementRef: true,
38
+ /**
39
+ * Although axe-core can perform iframe scanning, I haven't succeeded in it,
40
+ * and the docs suggest that the axe-core script should be explicitly included
41
+ * in each of the iframed documents anyway.
42
+ * It seems preferable to disallow iframe scanning and not report issues in elements within iframes
43
+ * in the case that such issues are for some reason reported by axe-core.
44
+ * A consumer of Accented can instead scan the iframed document by calling Accented initialization from that document.
45
+ */
46
+ iframes: false,
47
+ /**
48
+ * The `preload` docs are not clear to me,
49
+ * but when it's set to `true` by default,
50
+ * axe-core tries to fetch cross-origin CSS,
51
+ * which fails in the absence of CORS headers.
52
+ * I'm not sure why axe-core needs to preload
53
+ * those resources in the first place,
54
+ * so disabling it seems to be the safe option.
55
+ */
56
+ preload: false,
57
+ /**
58
+ * We're only interested in violations,
59
+ * not in passes or incomplete results.
60
+ */
61
+ resultTypes: ['violations'],
62
+ };
13
63
  const axeRunningWindowProp = `__${name}_axe_running__`;
14
64
  const win = window;
15
65
  const taskQueue = new TaskQueue(async (nodes) => {
16
- // We may see errors coming from axe-core when Accented is toggled off and on in qiuck succession,
66
+ // We may see errors coming from axe-core when Accented is toggled off and on in quick succession,
17
67
  // which I've seen happen with hot reloading of a React application.
18
68
  // This window property serves as a circuit breaker for that particular case.
19
69
  if (win[axeRunningWindowProp]) {
@@ -22,42 +72,29 @@ export function createScanner(name, context, axeOptions, throttle, callback) {
22
72
  try {
23
73
  performance.mark('scan-start');
24
74
  win[axeRunningWindowProp] = true;
25
- const scanContext = getScanContext(nodes, context);
26
- let result;
75
+ const limitedContext = getScanContext(nodes, context);
76
+ let limitedContextResult;
77
+ let fullContextResult;
27
78
  try {
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
- */
34
- elementRef: true,
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
- */
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
- */
58
- resultTypes: ['violations'],
59
- ...axeOptions,
60
- });
79
+ // Run the scan against the limited context (only the mutated
80
+ // nodes, filtered to those within the user-provided context). Skip if no
81
+ // limited-context rules are active.
82
+ limitedContextResult =
83
+ limitedContextRules.size > 0
84
+ ? await axe.run(limitedContext, {
85
+ ...baseAxeOptions,
86
+ runOnly: { type: 'rule', values: [...limitedContextRules] },
87
+ })
88
+ : undefined;
89
+ // Run the supplemental scan against the full context so that ancestor-
90
+ // dependent rules always see the complete DOM. Skip if none are active.
91
+ fullContextResult =
92
+ fullContextRules.size > 0
93
+ ? await axe.run(context, {
94
+ ...baseAxeOptions,
95
+ runOnly: { type: 'rule', values: [...fullContextRules] },
96
+ })
97
+ : undefined;
61
98
  }
62
99
  catch (error) {
63
100
  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);
@@ -65,14 +102,15 @@ export function createScanner(name, context, axeOptions, throttle, callback) {
65
102
  win[axeRunningWindowProp] = false;
66
103
  const scanMeasure = performance.measure('scan', 'scan-start');
67
104
  const scanDuration = Math.round(scanMeasure.duration);
68
- if (!enabled.value || !result) {
105
+ if (!enabled.value || (!limitedContextResult && !fullContextResult)) {
69
106
  return;
70
107
  }
71
108
  performance.mark('dom-update-start');
72
109
  updateElementsWithIssues({
73
110
  extendedElementsWithIssues,
74
- scanContext,
75
- violations: result.violations,
111
+ limitedContext,
112
+ limitedContextViolations: limitedContextResult?.violations ?? [],
113
+ fullContextViolations: fullContextResult?.violations ?? [],
76
114
  name,
77
115
  });
78
116
  const domUpdateMeasure = performance.measure('dom-update', 'dom-update-start');
@@ -81,7 +119,7 @@ export function createScanner(name, context, axeOptions, throttle, callback) {
81
119
  // Assuming that the {include, exclude} shape of the context object will be used less often
82
120
  // than other variants, we'll output just the `include` array in case nothing is excluded
83
121
  // in the scan.
84
- scanContext: scanContext.exclude.length > 0 ? scanContext : scanContext.include,
122
+ scanContext: limitedContext.exclude.length > 0 ? limitedContext : limitedContext.include,
85
123
  elementsWithIssues: elementsWithIssues.value,
86
124
  performance: {
87
125
  totalBlockingTime: scanDuration + domUpdateDuration,
@@ -1 +1 @@
1
- {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE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 -0,0 +1,3 @@
1
+ import type { ElementWithIssues, ExtendedElementWithIssues } from '../types.ts';
2
+ export declare function createExtendedElementWithIssues(elementWithIssues: ElementWithIssues, name: string): ExtendedElementWithIssues;
3
+ //# sourceMappingURL=create-extended-element-with-issues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-extended-element-with-issues.d.ts","sourceRoot":"","sources":["../../src/utils/create-extended-element-with-issues.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAyBhF,wBAAgB,+BAA+B,CAC7C,iBAAiB,EAAE,iBAAiB,EACpC,IAAI,EAAE,MAAM,GACX,yBAAyB,CAmC3B"}
@@ -0,0 +1,56 @@
1
+ import { signal } from '@preact/signals-core';
2
+ import { isSvgElement } from './dom-helpers.js';
3
+ import { getElementPosition } from './get-element-position.js';
4
+ import { getParent } from './get-parent.js';
5
+ import { getScrollableAncestors } from './get-scrollable-ancestors.js';
6
+ import { supportsAnchorPositioning } from './supports-anchor-positioning.js';
7
+ function shouldSkipRender(element) {
8
+ // Skip rendering if the element is inside an SVG:
9
+ // https://github.com/pomerantsev/accented/issues/62
10
+ const parent = getParent(element);
11
+ const isInsideSvg = Boolean(parent && isSvgElement(parent));
12
+ // Some issues, such as meta-viewport, are on <head> descendants,
13
+ // but since <head> is never rendered, we don't want to output anything
14
+ // for those in the DOM.
15
+ // We're not anticipating the use of shadow DOM in <head>,
16
+ // so the use of .closest() should be fine.
17
+ const isInsideHead = element.closest('head') !== null;
18
+ return isInsideSvg || isInsideHead;
19
+ }
20
+ let count = 0;
21
+ export function createExtendedElementWithIssues(elementWithIssues, name) {
22
+ const id = count++;
23
+ const trigger = document.createElement(`${name}-trigger`);
24
+ const elementZIndex = Number.parseInt(getComputedStyle(elementWithIssues.element).zIndex, 10);
25
+ if (!Number.isNaN(elementZIndex)) {
26
+ trigger.style.setProperty('z-index', (elementZIndex + 1).toString(), 'important');
27
+ }
28
+ trigger.style.setProperty('position-anchor', `--${name}-anchor-${id}`, 'important');
29
+ trigger.dataset.id = id.toString();
30
+ const accentedDialog = document.createElement(`${name}-dialog`);
31
+ trigger.dialog = accentedDialog;
32
+ const position = getElementPosition(elementWithIssues.element);
33
+ trigger.position = signal(position);
34
+ trigger.visible = signal(true);
35
+ trigger.element = elementWithIssues.element;
36
+ const scrollableAncestors = supportsAnchorPositioning()
37
+ ? new Set()
38
+ : getScrollableAncestors(elementWithIssues.element);
39
+ const issues = signal(elementWithIssues.issues);
40
+ accentedDialog.issues = issues;
41
+ accentedDialog.element = elementWithIssues.element;
42
+ return {
43
+ id,
44
+ element: elementWithIssues.element,
45
+ skipRender: shouldSkipRender(elementWithIssues.element),
46
+ rootNode: elementWithIssues.rootNode,
47
+ visible: trigger.visible,
48
+ position: trigger.position,
49
+ scrollableAncestors: signal(scrollableAncestors),
50
+ anchorNameValue: elementWithIssues.element.style.getPropertyValue('anchor-name') ||
51
+ getComputedStyle(elementWithIssues.element).getPropertyValue('anchor-name'),
52
+ trigger,
53
+ issues,
54
+ };
55
+ }
56
+ //# sourceMappingURL=create-extended-element-with-issues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-extended-element-with-issues.js","sourceRoot":"","sources":["../../src/utils/create-extended-element-with-issues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,SAAS,gBAAgB,CAAC,OAAgB;IACxC,kDAAkD;IAClD,oDAAoD;IACpD,MAAM,MAAM,GAAG,SAAS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CAAC;IAC/D,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpC,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,CAAC,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC;IAC5C,MAAM,mBAAmB,GAAG,yBAAyB,EAAE;QACrD,CAAC,CAAC,IAAI,GAAG,EAAe;QACxB,CAAC,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAChD,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;IAC/B,cAAc,CAAC,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC;IACnD,OAAO;QACL,EAAE;QACF,OAAO,EAAE,iBAAiB,CAAC,OAAO;QAClC,UAAU,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CAAC;QACvD,QAAQ,EAAE,iBAAiB,CAAC,QAAQ;QACpC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,CAAC;QAChD,eAAe,EACb,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC;YAC/D,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC;QAC7E,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AxeOptions } from '../types.ts';
2
+ export declare function getAllRulesFromAxeOptions(axeOptions: AxeOptions): Set<string>;
3
+ //# sourceMappingURL=get-all-rules-from-axe-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-all-rules-from-axe-options.d.ts","sourceRoot":"","sources":["../../src/utils/get-all-rules-from-axe-options.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA6B9C,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,CAiB7E"}
@@ -0,0 +1,51 @@
1
+ /* Adapts two axe-core behaviors:
2
+ - shorthand string/array runOnly normalization from normalizeOptions:
3
+ https://github.com/dequelabs/axe-core/blob/9261d074b60527a84f4dce5a64a6d5a5843a0772/lib/core/base/audit.js#L408-L428
4
+ - which rules to include for a given runOnly/rules combination, from ruleShouldRun (lines 65–80,
5
+ omitting the rule.pageLevel check — axe applies that itself when we call axe.run):
6
+ https://github.com/dequelabs/axe-core/blob/9261d074b60527a84f4dce5a64a6d5a5843a0772/lib/core/utils/rule-should-run.js */
7
+ import axe from 'axe-core';
8
+ function getRuleIds(tags) {
9
+ return new Set(axe.getRules(tags).map((r) => r.ruleId));
10
+ }
11
+ function applyOverrides(ruleSet, rules) {
12
+ if (!rules)
13
+ return ruleSet;
14
+ for (const [ruleId, ruleConfig] of Object.entries(rules)) {
15
+ if (ruleConfig.enabled === false)
16
+ ruleSet.delete(ruleId);
17
+ else if (ruleConfig.enabled === true)
18
+ ruleSet.add(ruleId);
19
+ }
20
+ return ruleSet;
21
+ }
22
+ // Normalizes the string/array shorthands of runOnly into the { type, values } object form.
23
+ function normalizeRunOnly(runOnly, allRuleIds) {
24
+ if (typeof runOnly !== 'string' && !Array.isArray(runOnly))
25
+ return runOnly;
26
+ const values = typeof runOnly === 'string' ? [runOnly] : runOnly;
27
+ const isRulePath = values.every((v) => allRuleIds.has(v));
28
+ const isTagPath = values.every((v) => !allRuleIds.has(v));
29
+ if (!isRulePath && !isTagPath)
30
+ throw new Error(`runOnly mixes rule IDs and tag values: ${values.join(', ')}`);
31
+ return { type: isRulePath ? 'rule' : 'tag', values };
32
+ }
33
+ export function getAllRulesFromAxeOptions(axeOptions) {
34
+ const allRuleIds = getRuleIds();
35
+ const { rules, runOnly } = axeOptions;
36
+ if (runOnly === undefined) {
37
+ // axe.getRules() includes rules disabled by default; axe skips them via rule.enabled !== false.
38
+ // Replicate that here using the internal _audit.rules, which exposes the enabled flag.
39
+ // @ts-expect-error: _audit is an undocumented internal axe-core API not present in its type definitions
40
+ for (const rule of axe._audit.rules) {
41
+ if (rule.enabled === false)
42
+ allRuleIds.delete(rule.id);
43
+ }
44
+ return applyOverrides(allRuleIds, rules);
45
+ }
46
+ const { type, values } = normalizeRunOnly(runOnly, allRuleIds);
47
+ if (type === 'rule' || type === 'rules')
48
+ return new Set(values);
49
+ return applyOverrides(getRuleIds(values), rules);
50
+ }
51
+ //# sourceMappingURL=get-all-rules-from-axe-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-all-rules-from-axe-options.js","sourceRoot":"","sources":["../../src/utils/get-all-rules-from-axe-options.ts"],"names":[],"mappings":"AAAA;;;;;6HAK6H;AAC7H,OAAO,GAAG,MAAM,UAAU,CAAC;AAG3B,SAAS,UAAU,CAAC,IAAoB;IACtC,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,cAAc,CAAC,OAAoB,EAAE,KAA0B;IACtE,IAAI,CAAC,KAAK;QAAE,OAAO,OAAO,CAAC;IAC3B,KAAK,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,IAAI,UAAU,CAAC,OAAO,KAAK,KAAK;YAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;aACpD,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI;YAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;A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,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC/D,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAChE,OAAO,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;AACnD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"transform-violations.d.ts","sourceRoot":"","sources":["../../src/utils/transform-violations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,iBAAiB,EAAS,MAAM,aAAa,CAAC;AAyB5D,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,OAAO,UAAU,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,uBAsDzF"}
1
+ {"version":3,"file":"transform-violations.d.ts","sourceRoot":"","sources":["../../src/utils/transform-violations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,iBAAiB,EAAS,MAAM,aAAa,CAAC;AAa5D,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,OAAO,UAAU,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,uBAsDzF"}
@@ -1,17 +1,6 @@
1
- import { issuesUrl, orderedImpacts } from '../constants.js';
2
- // This is a list of axe-core violations (their ids) that may be flagged by axe-core
3
- // as false positives if an Accented trigger is a descendant of the element with the issue.
4
- const violationsAffectedByAccentedTriggers = [
5
- 'aria-hidden-focus',
6
- 'aria-text',
7
- 'definition-list',
8
- 'label-content-name-mismatch',
9
- 'list',
10
- 'nested-interactive',
11
- 'scrollable-region-focusable', // The Accented trigger might make the content grow such that scrolling is required.
12
- ];
1
+ import { issuesUrl, orderedImpacts, violationsAffectedByAccentedTriggers } from '../constants.js';
13
2
  function maybeCausedByAccented(violationId, element, name) {
14
- return (violationsAffectedByAccentedTriggers.includes(violationId) &&
3
+ return (violationsAffectedByAccentedTriggers.has(violationId) &&
15
4
  Boolean(element.querySelector(`${name}-trigger`)));
16
5
  }
17
6
  function impactCompare(a, b) {
@@ -1 +1 @@
1
- {"version":3,"file":"transform-violations.js","sourceRoot":"","sources":["../../src/utils/transform-violations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAG5D,oFAAoF;AACpF,2FAA2F;AAC3F,MAAM,oCAAoC,GAAG;IAC3C,mBAAmB;IACnB,WAAW;IACX,iBAAiB;IACjB,6BAA6B;IAC7B,MAAM;IACN,oBAAoB;IACpB,6BAA6B,EAAE,oFAAoF;CACpH,CAAC;AAEF,SAAS,qBAAqB,CAAC,WAAmB,EAAE,OAAoB,EAAE,IAAY;IACpF,OAAO,CACL,oCAAoC,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC1D,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,CAClD,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,CAAkB,EAAE,CAAkB;IAC3D,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,UAAwC,EAAE,IAAY;IACxF,MAAM,kBAAkB,GAA6B,EAAE,CAAC;IAExD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;YACnC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YAEjC,4EAA4E;YAC5E,8EAA8E;YA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AAO,kBAAkB,CAAC;AAC5B,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import type { Signal } from '@preact/signals-core';
2
2
  import type { AxeResults } from 'axe-core';
3
3
  import type { ExtendedElementWithIssues, ScanContext } from '../types.ts';
4
- export declare function updateElementsWithIssues({ extendedElementsWithIssues, scanContext, violations, name, }: {
4
+ export declare function updateElementsWithIssues({ extendedElementsWithIssues, limitedContext, limitedContextViolations, fullContextViolations, name, }: {
5
5
  extendedElementsWithIssues: Signal<Array<ExtendedElementWithIssues>>;
6
- scanContext: ScanContext;
7
- violations: typeof AxeResults.violations;
6
+ limitedContext: ScanContext;
7
+ limitedContextViolations: AxeResults['violations'];
8
+ fullContextViolations: AxeResults['violations'];
8
9
  name: string;
9
10
  }): void;
10
11
  //# sourceMappingURL=update-elements-with-issues.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-elements-with-issues.d.ts","sourceRoot":"","sources":["../../src/utils/update-elements-with-issues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,KAAK,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA6B1E,wBAAgB,wBAAwB,CAAC,EACvC,0BAA0B,EAC1B,WAAW,EACX,UAAU,EACV,IAAI,GACL,EAAE;IACD,0BAA0B,EAAE,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;IACrE,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,OAAO,UAAU,CAAC,UAAU,CAAC;IACzC,IAAI,EAAE,MAAM,CAAC;CACd,QA+FA"}
1
+ {"version":3,"file":"update-elements-with-issues.d.ts","sourceRoot":"","sources":["../../src/utils/update-elements-with-issues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAGV,yBAAyB,EAEzB,WAAW,EACZ,MAAM,aAAa,CAAC;AA+BrB,wBAAgB,wBAAwB,CAAC,EACvC,0BAA0B,EAC1B,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,IAAI,GACL,EAAE;IACD,0BAA0B,EAAE,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;IACrE,cAAc,EAAE,WAAW,CAAC;IAC5B,wBAAwB,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACnD,qBAAqB,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IAChD,IAAI,EAAE,MAAM,CAAC;CACd,QAuDA"}
@@ -1,93 +1,49 @@
1
- import { batch, signal } from '@preact/signals-core';
1
+ import { batch } from '@preact/signals-core';
2
+ import { descendantDependentRules } from '../constants.js';
2
3
  import { areElementsWithIssuesEqual } from './are-elements-with-issues-equal.js';
3
4
  import { areIssueSetsEqual } from './are-issue-sets-equal.js';
4
- import { isSvgElement } from './dom-helpers.js';
5
- import { getElementPosition } from './get-element-position.js';
6
- import { getParent } from './get-parent.js';
7
- import { getScrollableAncestors } from './get-scrollable-ancestors.js';
5
+ import { createExtendedElementWithIssues } from './create-extended-element-with-issues.js';
8
6
  import { isNodeInScanContext } from './is-node-in-scan-context.js';
9
- import { supportsAnchorPositioning } from './supports-anchor-positioning.js';
10
7
  import { transformViolations } from './transform-violations.js';
11
- function shouldSkipRender(element) {
12
- // Skip rendering if the element is inside an SVG:
13
- // https://github.com/pomerantsev/accented/issues/62
14
- const parent = getParent(element);
15
- const isInsideSvg = Boolean(parent && isSvgElement(parent));
16
- // Some issues, such as meta-viewport, are on <head> descendants,
17
- // but since <head> is never rendered, we don't want to output anything
18
- // for those in the DOM.
19
- // We're not anticipating the use of shadow DOM in <head>,
20
- // so the use of .closest() should be fine.
21
- const isInsideHead = element.closest('head') !== null;
22
- return isInsideSvg || isInsideHead;
8
+ function getIssuesForElement(element, list) {
9
+ return list.find((entry) => areElementsWithIssuesEqual(entry, element))?.issues ?? [];
23
10
  }
24
- let count = 0;
25
- export function updateElementsWithIssues({ extendedElementsWithIssues, scanContext, violations, name, }) {
26
- const updatedElementsWithIssues = transformViolations(violations, name);
11
+ function mergeLimitedContextAndFullContextViolations(elementsFromLimitedContext, elementsFromFullContext) {
12
+ const fromLimitedWithFullIssuesMerged = elementsFromLimitedContext.map((limited) => {
13
+ const fullMatch = elementsFromFullContext.find((full) => areElementsWithIssuesEqual(full, limited));
14
+ return fullMatch ? { ...limited, issues: [...limited.issues, ...fullMatch.issues] } : limited;
15
+ });
16
+ const onlyInFullContext = elementsFromFullContext.filter((full) => !elementsFromLimitedContext.some((limited) => areElementsWithIssuesEqual(limited, full)));
17
+ return [...fromLimitedWithFullIssuesMerged, ...onlyInFullContext];
18
+ }
19
+ export function updateElementsWithIssues({ extendedElementsWithIssues, limitedContext, limitedContextViolations, fullContextViolations, name, }) {
20
+ const updatedElementsFromLimitedContext = transformViolations(limitedContextViolations, name);
21
+ const updatedElementsFromFullContext = transformViolations(fullContextViolations, name);
22
+ const allUpdatedElements = mergeLimitedContextAndFullContextViolations(updatedElementsFromLimitedContext, updatedElementsFromFullContext);
27
23
  batch(() => {
28
- for (const updatedElementWithIssues of updatedElementsWithIssues) {
29
- const existingElementIndex = extendedElementsWithIssues.value.findIndex((extendedElementWithIssues) => areElementsWithIssuesEqual(extendedElementWithIssues, updatedElementWithIssues));
30
- if (existingElementIndex > -1 &&
31
- extendedElementsWithIssues.value[existingElementIndex] &&
32
- !areIssueSetsEqual(extendedElementsWithIssues.value[existingElementIndex].issues.value, updatedElementWithIssues.issues)) {
33
- extendedElementsWithIssues.value[existingElementIndex].issues.value =
34
- updatedElementWithIssues.issues;
24
+ for (const existing of extendedElementsWithIssues.value) {
25
+ // If the element is inside the limited context, axe just rescanned
26
+ // it replace its issues with whatever was reported. If it's outside, keep its
27
+ // existing issues, except descendant-dependent ones, which may have changed due
28
+ // to mutations elsewhere; those get repopulated from the full-context scan below.
29
+ const newLimitedContextIssues = isNodeInScanContext(existing.element, limitedContext)
30
+ ? getIssuesForElement(existing, updatedElementsFromLimitedContext)
31
+ : existing.issues.value.filter((issue) => !descendantDependentRules.has(issue.id));
32
+ const newFullContextIssues = getIssuesForElement(existing, updatedElementsFromFullContext);
33
+ const newIssues = [...newLimitedContextIssues, ...newFullContextIssues];
34
+ if (!areIssueSetsEqual(existing.issues.value, newIssues)) {
35
+ existing.issues.value = newIssues;
35
36
  }
36
37
  }
37
- const addedElementsWithIssues = updatedElementsWithIssues.filter((updatedElementWithIssues) => {
38
- return !extendedElementsWithIssues.value.some((extendedElementWithIssues) => areElementsWithIssuesEqual(extendedElementWithIssues, updatedElementWithIssues));
39
- });
40
- // Only consider an element to be removed in two cases:
41
- // 1. It has been removed from the DOM.
42
- // 2. It is within the scan context, but not among updatedElementsWithIssues.
43
- const removedElementsWithIssues = extendedElementsWithIssues.value.filter((extendedElementWithIssues) => {
44
- const isConnected = extendedElementWithIssues.element.isConnected;
45
- const hasNoMoreIssues = isNodeInScanContext(extendedElementWithIssues.element, scanContext) &&
46
- !updatedElementsWithIssues.some((updatedElementWithIssues) => areElementsWithIssuesEqual(updatedElementWithIssues, extendedElementWithIssues));
47
- return !isConnected || hasNoMoreIssues;
48
- });
38
+ const addedElementsWithIssues = allUpdatedElements.filter((updated) => updated.element.isConnected &&
39
+ !extendedElementsWithIssues.value.some((existing) => areElementsWithIssuesEqual(existing, updated)));
40
+ const removedElementsWithIssues = extendedElementsWithIssues.value.filter((existing) => !existing.element.isConnected || existing.issues.value.length === 0);
41
+ // Only rebuild the outer signal when set membership changes; per-element issue
42
+ // updates were already made in the loop above.
49
43
  if (addedElementsWithIssues.length > 0 || removedElementsWithIssues.length > 0) {
50
44
  extendedElementsWithIssues.value = [...extendedElementsWithIssues.value]
51
- .filter((extendedElementWithIssues) => {
52
- return !removedElementsWithIssues.some((removedElementWithIssues) => areElementsWithIssuesEqual(removedElementWithIssues, extendedElementWithIssues));
53
- })
54
- .concat(addedElementsWithIssues
55
- .filter((addedElementWithIssues) => addedElementWithIssues.element.isConnected)
56
- .map((addedElementWithIssues) => {
57
- const id = count++;
58
- const trigger = document.createElement(`${name}-trigger`);
59
- const elementZIndex = Number.parseInt(getComputedStyle(addedElementWithIssues.element).zIndex, 10);
60
- if (!Number.isNaN(elementZIndex)) {
61
- trigger.style.setProperty('z-index', (elementZIndex + 1).toString(), 'important');
62
- }
63
- trigger.style.setProperty('position-anchor', `--${name}-anchor-${id}`, 'important');
64
- trigger.dataset.id = id.toString();
65
- const accentedDialog = document.createElement(`${name}-dialog`);
66
- trigger.dialog = accentedDialog;
67
- const position = getElementPosition(addedElementWithIssues.element);
68
- trigger.position = signal(position);
69
- trigger.visible = signal(true);
70
- trigger.element = addedElementWithIssues.element;
71
- const scrollableAncestors = supportsAnchorPositioning()
72
- ? new Set()
73
- : getScrollableAncestors(addedElementWithIssues.element);
74
- const issues = signal(addedElementWithIssues.issues);
75
- accentedDialog.issues = issues;
76
- accentedDialog.element = addedElementWithIssues.element;
77
- return {
78
- id,
79
- element: addedElementWithIssues.element,
80
- skipRender: shouldSkipRender(addedElementWithIssues.element),
81
- rootNode: addedElementWithIssues.rootNode,
82
- visible: trigger.visible,
83
- position: trigger.position,
84
- scrollableAncestors: signal(scrollableAncestors),
85
- anchorNameValue: addedElementWithIssues.element.style.getPropertyValue('anchor-name') ||
86
- getComputedStyle(addedElementWithIssues.element).getPropertyValue('anchor-name'),
87
- trigger,
88
- issues,
89
- };
90
- }));
45
+ .filter((existing) => !removedElementsWithIssues.some((removed) => areElementsWithIssuesEqual(removed, existing)))
46
+ .concat(addedElementsWithIssues.map((added) => createExtendedElementWithIssues(added, name)));
91
47
  }
92
48
  });
93
49
  }