govuk_publishing_components 21.16.3 → 21.17.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 (230) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/component_guide/accessibility-test.js +0 -6
  3. data/app/views/govuk_publishing_components/components/docs/machine_readable_metadata.yml +7 -0
  4. data/lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb +34 -0
  5. data/lib/govuk_publishing_components/presenters/schema_org.rb +3 -0
  6. data/lib/govuk_publishing_components/version.rb +1 -1
  7. data/node_modules/axe-core/CHANGELOG.md +166 -2
  8. data/node_modules/axe-core/CONTRIBUTING.md +5 -5
  9. data/node_modules/axe-core/README.md +4 -4
  10. data/node_modules/axe-core/axe.d.ts +27 -11
  11. data/node_modules/axe-core/axe.js +9597 -2431
  12. data/node_modules/axe-core/axe.min.js +2 -2
  13. data/node_modules/axe-core/bower.json +1 -1
  14. data/node_modules/axe-core/doc/API.md +211 -128
  15. data/node_modules/axe-core/doc/accessibility-supported.md +1 -1
  16. data/node_modules/axe-core/doc/aria-supported.md +4 -13
  17. data/node_modules/axe-core/doc/backwards-compatibility-doc.md +93 -0
  18. data/node_modules/axe-core/doc/code-submission-guidelines.md +4 -4
  19. data/node_modules/axe-core/doc/developer-guide.md +27 -13
  20. data/node_modules/axe-core/doc/examples/chrome-debugging-protocol/package.json +5 -2
  21. data/node_modules/axe-core/doc/examples/jasmine/README.md +3 -5
  22. data/node_modules/axe-core/doc/examples/jasmine/karma.conf.js +29 -0
  23. data/node_modules/axe-core/doc/examples/jasmine/package.json +6 -5
  24. data/node_modules/axe-core/doc/examples/jest_react/README.md +1 -1
  25. data/node_modules/axe-core/doc/examples/jest_react/link.test.js +3 -3
  26. data/node_modules/axe-core/doc/examples/jest_react/package.json +9 -9
  27. data/node_modules/axe-core/doc/examples/jsdom/package.json +15 -0
  28. data/node_modules/axe-core/doc/examples/mocha/README.md +5 -7
  29. data/node_modules/axe-core/doc/examples/mocha/karma.conf.js +29 -0
  30. data/node_modules/axe-core/doc/examples/mocha/package.json +7 -6
  31. data/node_modules/axe-core/doc/examples/phantomjs/README.md +3 -3
  32. data/node_modules/axe-core/doc/examples/phantomjs/axe-phantom.js +4 -2
  33. data/node_modules/axe-core/doc/examples/phantomjs/package.json +3 -3
  34. data/node_modules/axe-core/doc/examples/puppeteer/package.json +5 -2
  35. data/node_modules/axe-core/doc/examples/qunit/README.md +2 -2
  36. data/node_modules/axe-core/doc/examples/qunit/package.json +2 -2
  37. data/node_modules/axe-core/doc/examples/test-examples.js +32 -0
  38. data/node_modules/axe-core/doc/plugins.md +10 -10
  39. data/node_modules/axe-core/doc/projects.md +12 -8
  40. data/node_modules/axe-core/doc/rule-descriptions.md +87 -79
  41. data/node_modules/axe-core/doc/rule-development.md +30 -2
  42. data/node_modules/axe-core/lib/checks/aria/allowed-attr.js +1 -1
  43. data/node_modules/axe-core/lib/checks/aria/aria-roledescription.js +14 -0
  44. data/node_modules/axe-core/lib/checks/aria/aria-roledescription.json +23 -0
  45. data/node_modules/axe-core/lib/checks/aria/no-implicit-explicit-label.js +21 -0
  46. data/node_modules/axe-core/lib/checks/aria/no-implicit-explicit-label.json +11 -0
  47. data/node_modules/axe-core/lib/checks/aria/required-attr.js +32 -7
  48. data/node_modules/axe-core/lib/checks/aria/required-children.js +40 -14
  49. data/node_modules/axe-core/lib/checks/aria/required-children.json +12 -1
  50. data/node_modules/axe-core/lib/checks/aria/required-parent.js +1 -1
  51. data/node_modules/axe-core/lib/checks/aria/unsupportedattr.js +1 -1
  52. data/node_modules/axe-core/lib/checks/aria/valid-attr-value.js +50 -17
  53. data/node_modules/axe-core/lib/checks/aria/valid-attr-value.json +2 -1
  54. data/node_modules/axe-core/lib/checks/aria/valid-attr.js +1 -1
  55. data/node_modules/axe-core/lib/checks/color/color-contrast.js +2 -2
  56. data/node_modules/axe-core/lib/checks/forms/autocomplete-appropriate.js +4 -4
  57. data/node_modules/axe-core/lib/checks/forms/autocomplete-valid.js +1 -1
  58. data/node_modules/axe-core/lib/checks/forms/fieldset.json +1 -0
  59. data/node_modules/axe-core/lib/checks/forms/group-labelledby.json +1 -0
  60. data/node_modules/axe-core/lib/checks/keyboard/focusable-content.js +16 -0
  61. data/node_modules/axe-core/lib/checks/keyboard/focusable-content.json +11 -0
  62. data/node_modules/axe-core/lib/checks/keyboard/focusable-element.js +12 -0
  63. data/node_modules/axe-core/lib/checks/keyboard/focusable-element.json +11 -0
  64. data/node_modules/axe-core/lib/checks/keyboard/tabindex.js +6 -1
  65. data/node_modules/axe-core/lib/checks/label/alt-space-value.js +3 -2
  66. data/node_modules/axe-core/lib/checks/label/duplicate-img-label.js +18 -15
  67. data/node_modules/axe-core/lib/checks/label/label-content-name-mismatch.js +13 -3
  68. data/node_modules/axe-core/lib/checks/label/label-content-name-mismatch.json +4 -0
  69. data/node_modules/axe-core/lib/checks/label/multiple-label.js +22 -12
  70. data/node_modules/axe-core/lib/checks/label/multiple-label.json +1 -1
  71. data/node_modules/axe-core/lib/checks/landmarks/landmark-is-unique-after.js +23 -0
  72. data/node_modules/axe-core/lib/checks/landmarks/landmark-is-unique.js +7 -0
  73. data/node_modules/axe-core/lib/checks/landmarks/landmark-is-unique.json +12 -0
  74. data/node_modules/axe-core/lib/checks/lists/listitem.js +1 -0
  75. data/node_modules/axe-core/lib/checks/lists/listitem.json +1 -1
  76. data/node_modules/axe-core/lib/checks/lists/only-listitems.js +0 -4
  77. data/node_modules/axe-core/lib/checks/mobile/css-orientation-lock.js +8 -6
  78. data/node_modules/axe-core/lib/checks/navigation/region.js +2 -19
  79. data/node_modules/axe-core/lib/checks/shared/avoid-inline-spacing.js +18 -0
  80. data/node_modules/axe-core/lib/checks/shared/avoid-inline-spacing.json +11 -0
  81. data/node_modules/axe-core/lib/checks/shared/exists.js +1 -1
  82. data/node_modules/axe-core/lib/checks/shared/exists.json +1 -1
  83. data/node_modules/axe-core/lib/checks/shared/has-alt.js +6 -4
  84. data/node_modules/axe-core/lib/checks/shared/non-empty-alt.js +1 -1
  85. data/node_modules/axe-core/lib/checks/tables/caption-faked.json +1 -1
  86. data/node_modules/axe-core/lib/checks/tables/td-has-header.js +5 -4
  87. data/node_modules/axe-core/lib/checks/tables/th-has-data-cells.js +19 -29
  88. data/node_modules/axe-core/lib/commons/aria/get-owned-virtual.js +1 -1
  89. data/node_modules/axe-core/lib/commons/aria/index.js +50 -46
  90. data/node_modules/axe-core/lib/commons/aria/is-accessible-ref.js +41 -37
  91. data/node_modules/axe-core/lib/commons/aria/label-virtual.js +2 -2
  92. data/node_modules/axe-core/lib/commons/aria/roles.js +1 -1
  93. data/node_modules/axe-core/lib/commons/aria/validate-attr-value.js +0 -1
  94. data/node_modules/axe-core/lib/commons/color/center-point-of-rect.js +30 -0
  95. data/node_modules/axe-core/lib/commons/color/contrast.js +7 -1
  96. data/node_modules/axe-core/lib/commons/color/element-has-image.js +36 -0
  97. data/node_modules/axe-core/lib/commons/color/get-background-color.js +332 -306
  98. data/node_modules/axe-core/lib/commons/color/get-foreground-color.js +35 -6
  99. data/node_modules/axe-core/lib/commons/color/get-own-background-color.js +22 -0
  100. data/node_modules/axe-core/lib/commons/dom/find-up.js +5 -5
  101. data/node_modules/axe-core/lib/commons/dom/get-scroll-offset.js +0 -1
  102. data/node_modules/axe-core/lib/commons/dom/get-tabbable-elements.js +1 -1
  103. data/node_modules/axe-core/lib/commons/dom/has-content-virtual.js +7 -5
  104. data/node_modules/axe-core/lib/commons/dom/is-focusable.js +8 -5
  105. data/node_modules/axe-core/lib/commons/dom/is-hidden-with-css.js +15 -2
  106. data/node_modules/axe-core/lib/commons/dom/is-in-text-block.js +1 -2
  107. data/node_modules/axe-core/lib/commons/dom/is-skip-link.js +45 -0
  108. data/node_modules/axe-core/lib/commons/dom/is-visible.js +43 -17
  109. data/node_modules/axe-core/lib/commons/dom/is-visual-content.js +0 -1
  110. data/node_modules/axe-core/lib/commons/dom/visually-contains.js +0 -1
  111. data/node_modules/axe-core/lib/commons/dom/visually-overlaps.js +0 -1
  112. data/node_modules/axe-core/lib/commons/forms/index.js +8 -0
  113. data/node_modules/axe-core/lib/commons/forms/is-aria-combobox.js +13 -0
  114. data/node_modules/axe-core/lib/commons/forms/is-aria-listbox.js +13 -0
  115. data/node_modules/axe-core/lib/commons/forms/is-aria-range.js +14 -0
  116. data/node_modules/axe-core/lib/commons/forms/is-aria-textbox.js +13 -0
  117. data/node_modules/axe-core/lib/commons/forms/is-native-select.js +13 -0
  118. data/node_modules/axe-core/lib/commons/forms/is-native-textbox.js +28 -0
  119. data/node_modules/axe-core/lib/commons/table/get-cell-position.js +2 -2
  120. data/node_modules/axe-core/lib/commons/table/get-headers.js +55 -11
  121. data/node_modules/axe-core/lib/commons/table/get-scope.js +1 -1
  122. data/node_modules/axe-core/lib/commons/table/is-data-table.js +0 -1
  123. data/node_modules/axe-core/lib/commons/table/to-grid.js +2 -2
  124. data/node_modules/axe-core/lib/commons/text/accessible-text-virtual.js +5 -5
  125. data/node_modules/axe-core/lib/commons/text/form-control-value.js +18 -30
  126. data/node_modules/axe-core/lib/commons/text/is-icon-ligature.js +210 -0
  127. data/node_modules/axe-core/lib/commons/text/is-valid-autocomplete.js +0 -1
  128. data/node_modules/axe-core/lib/commons/text/label-text.js +1 -1
  129. data/node_modules/axe-core/lib/commons/text/label-virtual.js +1 -1
  130. data/node_modules/axe-core/lib/commons/text/native-text-methods.js +1 -1
  131. data/node_modules/axe-core/lib/commons/text/subtree-text.js +3 -3
  132. data/node_modules/axe-core/lib/commons/text/unicode.js +15 -0
  133. data/node_modules/axe-core/lib/commons/text/visible-text-nodes.js +25 -0
  134. data/node_modules/axe-core/lib/commons/text/visible-virtual.js +1 -1
  135. data/node_modules/axe-core/lib/core/base/audit.js +90 -15
  136. data/node_modules/axe-core/lib/core/base/cache.js +33 -0
  137. data/node_modules/axe-core/lib/core/base/check.js +48 -1
  138. data/node_modules/axe-core/lib/core/base/context.js +15 -14
  139. data/node_modules/axe-core/lib/core/base/rule.js +223 -46
  140. data/node_modules/axe-core/lib/core/base/virtual-node/abstract-virtual-node.js +40 -0
  141. data/node_modules/axe-core/lib/core/base/virtual-node/serial-virtual-node.js +86 -0
  142. data/node_modules/axe-core/lib/core/base/virtual-node/virtual-node.js +85 -0
  143. data/node_modules/axe-core/lib/core/constants.js +10 -2
  144. data/node_modules/axe-core/lib/core/imports/index.js +28 -3
  145. data/node_modules/axe-core/lib/core/index.js +2 -4
  146. data/node_modules/axe-core/lib/core/public/configure.js +28 -1
  147. data/node_modules/axe-core/lib/core/public/run-rules.js +2 -0
  148. data/node_modules/axe-core/lib/core/public/run-virtual-rule.js +50 -0
  149. data/node_modules/axe-core/lib/core/public/run.js +13 -2
  150. data/node_modules/axe-core/lib/core/reporters/helpers/process-aggregate.js +1 -1
  151. data/node_modules/axe-core/lib/core/reporters/na.js +4 -0
  152. data/node_modules/axe-core/lib/core/reporters/raw-env.js +12 -0
  153. data/node_modules/axe-core/lib/core/reporters/raw.js +25 -1
  154. data/node_modules/axe-core/lib/core/utils/are-styles-set.js +4 -7
  155. data/node_modules/axe-core/lib/core/utils/assert.js +12 -0
  156. data/node_modules/axe-core/lib/core/utils/collect-results-from-frames.js +2 -2
  157. data/node_modules/axe-core/lib/core/utils/contains.js +27 -13
  158. data/node_modules/axe-core/lib/core/utils/css-parser.js +2 -0
  159. data/node_modules/axe-core/lib/core/utils/element-matches.js +5 -1
  160. data/node_modules/axe-core/lib/core/utils/escape-selector.js +1 -2
  161. data/node_modules/axe-core/lib/core/utils/flattened-tree.js +47 -61
  162. data/node_modules/axe-core/lib/core/utils/get-check-option.js +0 -1
  163. data/node_modules/axe-core/lib/core/utils/get-friendly-uri-end.js +1 -1
  164. data/node_modules/axe-core/lib/core/utils/get-node-attributes.js +21 -0
  165. data/node_modules/axe-core/lib/core/utils/get-scroll.js +39 -0
  166. data/node_modules/axe-core/lib/core/utils/get-selector.js +9 -6
  167. data/node_modules/axe-core/lib/core/utils/get-stylesheet-factory.js +51 -0
  168. data/node_modules/axe-core/lib/core/utils/get-xpath.js +0 -1
  169. data/node_modules/axe-core/lib/core/utils/is-hidden.js +16 -4
  170. data/node_modules/axe-core/lib/core/utils/is-html-element.js +5 -5
  171. data/node_modules/axe-core/lib/core/utils/is-shadow-root.js +3 -3
  172. data/node_modules/axe-core/lib/core/utils/memoize.js +17 -0
  173. data/node_modules/axe-core/lib/core/utils/parse-crossorigin-stylesheet.js +53 -0
  174. data/node_modules/axe-core/lib/core/utils/parse-sameorigin-stylesheet.js +96 -0
  175. data/node_modules/axe-core/lib/core/utils/parse-stylesheet.js +70 -0
  176. data/node_modules/axe-core/lib/core/utils/performance-timer.js +7 -2
  177. data/node_modules/axe-core/lib/core/utils/preload-cssom.js +77 -281
  178. data/node_modules/axe-core/lib/core/utils/preload.js +49 -23
  179. data/node_modules/axe-core/lib/core/utils/qsa.js +39 -50
  180. data/node_modules/axe-core/lib/core/utils/respondable.js +20 -3
  181. data/node_modules/axe-core/lib/core/utils/rule-should-run.js +0 -1
  182. data/node_modules/axe-core/lib/core/utils/scroll-state.js +12 -25
  183. data/node_modules/axe-core/lib/core/utils/select.js +12 -23
  184. data/node_modules/axe-core/lib/core/utils/uuid.js +1 -2
  185. data/node_modules/axe-core/lib/intro.stub +1 -1
  186. data/node_modules/axe-core/lib/misc/incomplete-fallback.json +1 -1
  187. data/node_modules/axe-core/lib/rules/aria-allowed-attr-matches.js +1 -1
  188. data/node_modules/axe-core/lib/rules/aria-form-field-name-matches.js +50 -0
  189. data/node_modules/axe-core/lib/rules/aria-has-attr-matches.js +1 -1
  190. data/node_modules/axe-core/lib/rules/aria-hidden-focus.json +1 -1
  191. data/node_modules/axe-core/lib/rules/aria-input-field-name.json +13 -0
  192. data/node_modules/axe-core/lib/rules/aria-roledescription.json +12 -0
  193. data/node_modules/axe-core/lib/rules/aria-toggle-field-name.json +18 -0
  194. data/node_modules/axe-core/lib/rules/autocomplete-matches.js +14 -10
  195. data/node_modules/axe-core/lib/rules/avoid-inline-spacing.json +12 -0
  196. data/node_modules/axe-core/lib/rules/button-name.json +3 -5
  197. data/node_modules/axe-core/lib/rules/checkboxgroup.json +2 -1
  198. data/node_modules/axe-core/lib/rules/color-contrast-matches.js +37 -22
  199. data/node_modules/axe-core/lib/rules/duplicate-id-active-matches.js +1 -1
  200. data/node_modules/axe-core/lib/rules/duplicate-id-misc-matches.js +2 -2
  201. data/node_modules/axe-core/lib/rules/form-field-multiple-labels.json +1 -1
  202. data/node_modules/axe-core/lib/rules/html-has-lang.json +1 -0
  203. data/node_modules/axe-core/lib/rules/image-alt.json +1 -1
  204. data/node_modules/axe-core/lib/rules/img-redundant-alt.json +3 -3
  205. data/node_modules/axe-core/lib/rules/input-button-name.json +26 -0
  206. data/node_modules/axe-core/lib/rules/landmark-unique-matches.js +41 -0
  207. data/node_modules/axe-core/lib/rules/landmark-unique.json +13 -0
  208. data/node_modules/axe-core/lib/rules/link-name.json +5 -4
  209. data/node_modules/axe-core/lib/rules/meta-refresh.json +8 -1
  210. data/node_modules/axe-core/lib/rules/radiogroup.json +2 -1
  211. data/node_modules/axe-core/lib/rules/role-img-alt.json +18 -0
  212. data/node_modules/axe-core/lib/rules/scrollable-region-focusable-matches.js +30 -0
  213. data/node_modules/axe-core/lib/rules/scrollable-region-focusable.json +12 -0
  214. data/node_modules/axe-core/lib/rules/skip-link-matches.js +1 -1
  215. data/node_modules/axe-core/lib/rules/skip-link.json +1 -1
  216. data/node_modules/axe-core/lib/rules/video-description.json +3 -1
  217. data/node_modules/axe-core/locales/de.json +1 -5
  218. data/node_modules/axe-core/locales/es.json +773 -0
  219. data/node_modules/axe-core/locales/fr.json +15 -19
  220. data/node_modules/axe-core/locales/ja.json +65 -11
  221. data/node_modules/axe-core/locales/ko.json +777 -0
  222. data/node_modules/axe-core/locales/nl.json +35 -35
  223. data/node_modules/axe-core/locales/pt_BR.json +773 -0
  224. data/node_modules/axe-core/package.json +56 -52
  225. data/node_modules/axe-core/sri-history.json +20 -0
  226. data/node_modules/axe-core/typings/axe-core/axe-core-tests.ts +5 -15
  227. data/node_modules/govuk-frontend/package.json +10 -10
  228. metadata +62 -4
  229. data/node_modules/axe-core/doc/axelogo2018.png +0 -0
  230. data/node_modules/axe-core/lib/rules/role-not-button-matches.js +0 -1
@@ -0,0 +1,85 @@
1
+ // class is unused in the file...
2
+ // eslint-disable-next-line no-unused-vars
3
+ class VirtualNode extends axe.AbstractVirtualNode {
4
+ /**
5
+ * Wrap the real node and provide list of the flattened children
6
+ * @param {Node} node the node in question
7
+ * @param {VirtualNode} parent The parent VirtualNode
8
+ * @param {String} shadowId the ID of the shadow DOM to which this node belongs
9
+ */
10
+ constructor(node, parent, shadowId) {
11
+ super();
12
+ this.shadowId = shadowId;
13
+ this.children = [];
14
+ this.actualNode = node;
15
+ this.parent = parent;
16
+
17
+ this._isHidden = null; // will be populated by axe.utils.isHidden
18
+ this._cache = {};
19
+
20
+ if (axe._cache.get('nodeMap')) {
21
+ axe._cache.get('nodeMap').set(node, this);
22
+ }
23
+ }
24
+
25
+ // abstract Node properties so we can run axe in DOM-less environments.
26
+ // add to the prototype so memory is shared across all virtual nodes
27
+ get props() {
28
+ const { nodeType, nodeName, id, type } = this.actualNode;
29
+
30
+ return {
31
+ nodeType,
32
+ nodeName: nodeName.toLowerCase(),
33
+ id,
34
+ type
35
+ };
36
+ }
37
+
38
+ /**
39
+ * Get the value of the given attribute name.
40
+ * @param {String} attrName The name of the attribute.
41
+ * @return {String|null} The value of the attribute or null if the attribute does not exist
42
+ */
43
+ attr(attrName) {
44
+ if (typeof this.actualNode.getAttribute !== 'function') {
45
+ return null;
46
+ }
47
+
48
+ return this.actualNode.getAttribute(attrName);
49
+ }
50
+
51
+ /**
52
+ * Determine if the element has the given attribute.
53
+ * @param {String} attrName The name of the attribute
54
+ * @return {Boolean} True if the element has the attribute, false otherwise.
55
+ */
56
+ hasAttr(attrName) {
57
+ if (typeof this.actualNode.hasAttribute !== 'function') {
58
+ return false;
59
+ }
60
+
61
+ return this.actualNode.hasAttribute(attrName);
62
+ }
63
+
64
+ /**
65
+ * Determine if the element is focusable and cache the result.
66
+ * @return {Boolean} True if the element is focusable, false otherwise.
67
+ */
68
+ get isFocusable() {
69
+ if (!this._cache.hasOwnProperty('isFocusable')) {
70
+ this._cache.isFocusable = axe.commons.dom.isFocusable(this.actualNode);
71
+ }
72
+ return this._cache.isFocusable;
73
+ }
74
+
75
+ /**
76
+ * Return the list of tabbable elements for this element and cache the result.
77
+ * @return {VirtualNode[]}
78
+ */
79
+ get tabbableElements() {
80
+ if (!this._cache.hasOwnProperty('tabbableElements')) {
81
+ this._cache.tabbableElements = axe.commons.dom.getTabbableElements(this);
82
+ }
83
+ return this._cache.tabbableElements;
84
+ }
85
+ }
@@ -32,8 +32,16 @@
32
32
  resultGroups: [],
33
33
  resultGroupMap: {},
34
34
  impact: Object.freeze(['minor', 'moderate', 'serious', 'critical']),
35
- preloadAssets: Object.freeze(['cssom']), // overtime this array will grow with other preload asset types, this constant is to verify if a requested preload type by the user via the configuration is supported by axe.
36
- preloadAssetsTimeout: 10000
35
+ preload: Object.freeze({
36
+ /**
37
+ * array of supported & preload(able) asset types.
38
+ */
39
+ assets: ['cssom'],
40
+ /**
41
+ * timeout value when resolving preload(able) assets
42
+ */
43
+ timeout: 10000
44
+ })
37
45
  };
38
46
 
39
47
  definitions.forEach(function(definition) {
@@ -10,7 +10,31 @@
10
10
  * Polyfill `Promise`
11
11
  * Reference: https://www.npmjs.com/package/es6-promise
12
12
  */
13
- require('es6-promise').polyfill();
13
+ if (!('Promise' in window)) {
14
+ require('es6-promise').polyfill();
15
+ }
16
+
17
+ /**
18
+ * Polyfill required TypedArray and functions
19
+ * Reference https://github.com/zloirock/core-js/
20
+ */
21
+ if (!('Uint32Array' in window)) {
22
+ require('core-js/features/typed-array/uint32-array');
23
+ }
24
+ if (window.Uint32Array) {
25
+ if (!('some' in window.Uint32Array.prototype)) {
26
+ require('core-js/features/typed-array/some');
27
+ }
28
+ if (!('reduce' in window.Uint32Array.prototype)) {
29
+ require('core-js/features/typed-array/reduce');
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Polyfill `WeakMap`
35
+ * Reference: https://github.com/polygonplanet/weakmap-polyfill
36
+ */
37
+ require('weakmap-polyfill');
14
38
 
15
39
  /**
16
40
  * Namespace `axe.imports` which holds required external dependencies
@@ -21,6 +45,7 @@ require('es6-promise').polyfill();
21
45
  axe.imports = {
22
46
  axios: require('axios'),
23
47
  CssSelectorParser: require('css-selector-parser').CssSelectorParser,
24
- doT: require('dot'),
25
- emojiRegexText: require('emoji-regex')
48
+ doT: require('@deque/dot'),
49
+ emojiRegexText: require('emoji-regex'),
50
+ memoize: require('memoizee')
26
51
  };
@@ -1,6 +1,6 @@
1
1
  /*exported axe, commons */
2
2
  /*global axeFunction, module, define */
3
- // exported namespace for aXe
3
+ // exported namespace for axe
4
4
  /*eslint no-use-before-define: 0, no-unused-vars: 0*/
5
5
  var axe = axe || {};
6
6
  axe.version = '<%= pkg.version %>';
@@ -32,9 +32,7 @@ var commons;
32
32
  function SupportError(error) {
33
33
  this.name = 'SupportError';
34
34
  this.cause = error.cause;
35
- this.message = `\`${
36
- error.cause
37
- }\` - feature unsupported in your environment.`;
35
+ this.message = `\`${error.cause}\` - feature unsupported in your environment.`;
38
36
  if (error.ruleId) {
39
37
  this.ruleId = error.ruleId;
40
38
  this.message += ` Skipping ${this.ruleId} rule.`;
@@ -1,6 +1,5 @@
1
1
  /* global reporters */
2
2
  function configureChecksRulesAndBranding(spec) {
3
- /*eslint max-statements: ["error",21]*/
4
3
  'use strict';
5
4
  var audit;
6
5
 
@@ -9,6 +8,34 @@ function configureChecksRulesAndBranding(spec) {
9
8
  throw new Error('No audit configured');
10
9
  }
11
10
 
11
+ if (spec.axeVersion || spec.ver) {
12
+ let specVersion = spec.axeVersion || spec.ver;
13
+ if (!/^\d+\.\d+\.\d+(-canary)?/.test(specVersion)) {
14
+ throw new Error(`Invalid configured version ${specVersion}`);
15
+ }
16
+
17
+ let [version, canary] = specVersion.split('-');
18
+ let [major, minor, patch] = version.split('.').map(Number);
19
+
20
+ let [axeVersion, axeCanary] = axe.version.split('-');
21
+ let [axeMajor, axeMinor, axePatch] = axeVersion.split('.').map(Number);
22
+
23
+ if (
24
+ major !== axeMajor ||
25
+ axeMinor < minor ||
26
+ (axeMinor === minor && axePatch < patch) ||
27
+ (major === axeMajor &&
28
+ minor === axeMinor &&
29
+ patch === axePatch &&
30
+ canary &&
31
+ canary !== axeCanary)
32
+ ) {
33
+ throw new Error(
34
+ `Configured version ${specVersion} is not compatible with current axe version ${axe.version}`
35
+ );
36
+ }
37
+ }
38
+
12
39
  if (
13
40
  spec.reporter &&
14
41
  (typeof spec.reporter === 'function' || reporters[spec.reporter])
@@ -3,6 +3,8 @@
3
3
 
4
4
  // Clean up after resolve / reject
5
5
  function cleanup() {
6
+ axe._memoizedFns.forEach(fn => fn.clear());
7
+ axe._cache.clear();
6
8
  axe._tree = undefined;
7
9
  axe._selectorData = undefined;
8
10
  }
@@ -0,0 +1,50 @@
1
+ /* global helpers, SerialVirtualNode */
2
+
3
+ /**
4
+ * Run a rule in a non-browser environment
5
+ * @param {String} ruleId Id of the rule
6
+ * @param {VirtualNode} vNode The virtual node to run the rule against
7
+ * @param {Object} options (optional) Set of options passed into rules or checks
8
+ * @return {Object} axe results for the rule run
9
+ */
10
+ axe.runVirtualRule = function(ruleId, vNode, options = {}) {
11
+ options.reporter = options.reporter || axe._audit.reporter || 'v1';
12
+ axe._selectorData = {};
13
+
14
+ if (vNode instanceof axe.AbstractVirtualNode === false) {
15
+ vNode = new SerialVirtualNode(vNode);
16
+ }
17
+
18
+ let rule = axe._audit.rules.find(rule => rule.id === ruleId);
19
+
20
+ if (!rule) {
21
+ throw new Error('unknown rule `' + ruleId + '`');
22
+ }
23
+
24
+ // rule.prototype.gather calls axe.utils.isHidden which in turn calls
25
+ // window.getComputedStyle if the rule excludes hidden elements. we
26
+ // can avoid this call by forcing the rule to not exclude hidden
27
+ // elements
28
+ rule = Object.create(rule, { excludeHidden: { value: false } });
29
+
30
+ const context = {
31
+ include: [vNode]
32
+ };
33
+
34
+ const rawResults = rule.runSync(context, options);
35
+ axe.utils.publishMetaData(rawResults);
36
+ axe.utils.finalizeRuleResult(rawResults);
37
+ const results = axe.utils.aggregateResult([rawResults]);
38
+
39
+ results.violations.forEach(result =>
40
+ result.nodes.forEach(nodeResult => {
41
+ nodeResult.failureSummary = helpers.failureSummary(nodeResult);
42
+ })
43
+ );
44
+
45
+ return {
46
+ ...helpers.getEnvironmentData(),
47
+ ...results,
48
+ toolOptions: options
49
+ };
50
+ };
@@ -1,4 +1,3 @@
1
- /*eslint indent: 0, complexity:["error", 12]*/
2
1
  function isContext(potential) {
3
2
  'use strict';
4
3
  switch (true) {
@@ -81,7 +80,6 @@ function normalizeRunParams(context, options, callback) {
81
80
  * @return {Promise} Resolves with the axe results. Only available when natively supported
82
81
  */
83
82
  axe.run = function(context, options, callback) {
84
- /*eslint max-statements:["error",18] */
85
83
  'use strict';
86
84
  if (!axe._audit) {
87
85
  throw new Error('No audit configured');
@@ -109,11 +107,22 @@ axe.run = function(context, options, callback) {
109
107
  });
110
108
  }
111
109
 
110
+ if (axe._running) {
111
+ const err =
112
+ 'Axe is already running. Use `await axe.run()` to wait ' +
113
+ 'for the previous run to finish before starting a new run.';
114
+ callback(err);
115
+ reject(err);
116
+ return p;
117
+ }
118
+
119
+ axe._running = true;
112
120
  axe._runRules(
113
121
  context,
114
122
  options,
115
123
  function(rawResults, cleanup) {
116
124
  let respond = function(results) {
125
+ axe._running = false;
117
126
  cleanup();
118
127
  try {
119
128
  callback(null, results);
@@ -133,12 +142,14 @@ axe.run = function(context, options, callback) {
133
142
  respond(results);
134
143
  }
135
144
  } catch (err) {
145
+ axe._running = false;
136
146
  cleanup();
137
147
  callback(err);
138
148
  reject(err);
139
149
  }
140
150
  },
141
151
  function(err) {
152
+ axe._running = false;
142
153
  callback(err);
143
154
  reject(err);
144
155
  }
@@ -40,7 +40,7 @@ var resultKeys = axe.constants.resultGroups;
40
40
  */
41
41
 
42
42
  /**
43
- * Aggregrate and process the aXe results,
43
+ * Aggregrate and process the axe results,
44
44
  * adding desired data to nodes and relatedNodes in each rule result.
45
45
  *
46
46
  * Prepares result data for reporters.
@@ -3,6 +3,10 @@
3
3
  axe.addReporter('na', function(results, options, callback) {
4
4
  'use strict';
5
5
 
6
+ console.warn(
7
+ '"na" reporter will be deprecated in axe v4.0. Use the "v2" reporter instead.'
8
+ );
9
+
6
10
  if (typeof options === 'function') {
7
11
  callback = options;
8
12
  options = {};
@@ -0,0 +1,12 @@
1
+ /*global helpers */
2
+ axe.addReporter('rawEnv', function(results, options, callback) {
3
+ if (typeof options === 'function') {
4
+ callback = options;
5
+ options = {};
6
+ }
7
+ function rawCallback(raw) {
8
+ const env = helpers.getEnvironmentData();
9
+ callback({ raw, env });
10
+ }
11
+ axe.getReporter('raw')(results, options, rawCallback);
12
+ });
@@ -1,8 +1,32 @@
1
1
  axe.addReporter('raw', function(results, options, callback) {
2
2
  'use strict';
3
+
3
4
  if (typeof options === 'function') {
4
5
  callback = options;
5
6
  options = {};
6
7
  }
7
- callback(results);
8
+
9
+ // Guard against tests which don't pass an array as the first param here.
10
+ if (!results || !Array.isArray(results)) {
11
+ return callback(results);
12
+ }
13
+
14
+ const transformedResults = results.map(result => {
15
+ const transformedResult = { ...result };
16
+ const types = ['passes', 'violations', 'incomplete', 'inapplicable'];
17
+ for (const type of types) {
18
+ // Some tests don't include all of the types, so we have to guard against that here.
19
+ // TODO: ensure tests always use "proper" results to avoid having these hacks in production code paths.
20
+ if (transformedResult[type] && Array.isArray(transformedResult[type])) {
21
+ transformedResult[type] = transformedResult[type].map(typeResult => ({
22
+ ...typeResult,
23
+ node: typeResult.node.toJSON()
24
+ }));
25
+ }
26
+ }
27
+
28
+ return transformedResult;
29
+ });
30
+
31
+ callback(transformedResults);
8
32
  });
@@ -3,19 +3,16 @@
3
3
  function areStylesSet(el, styles, stopAt) {
4
4
  'use strict';
5
5
  var styl = window.getComputedStyle(el, null);
6
- var set = false;
7
6
  if (!styl) {
8
7
  return false;
9
8
  }
10
- styles.forEach(function(att) {
9
+ for (var i = 0; i < styles.length; ++i) {
10
+ var att = styles[i];
11
11
  if (styl.getPropertyValue(att.property) === att.value) {
12
- set = true;
12
+ return true;
13
13
  }
14
- });
15
- if (set) {
16
- return true;
17
14
  }
18
- if (el.nodeName.toUpperCase() === stopAt.toUpperCase() || !el.parentNode) {
15
+ if (!el.parentNode || el.nodeName.toUpperCase() === stopAt.toUpperCase()) {
19
16
  return false;
20
17
  }
21
18
  return areStylesSet(el.parentNode, styles, stopAt);
@@ -0,0 +1,12 @@
1
+ /* global axe*/
2
+
3
+ /**
4
+ * If the first argument is falsey, throw an error using the second argument as a message.
5
+ * @param {boolean} bool
6
+ * @param {string} message
7
+ */
8
+ axe.utils.assert = function assert(bool, message) {
9
+ if (!bool) {
10
+ throw new Error(message);
11
+ }
12
+ };
@@ -40,11 +40,11 @@ axe.utils.sendCommandToFrame = function(node, parameters, resolve, reject) {
40
40
  axe.utils.respondable(win, 'axe.ping', null, undefined, function() {
41
41
  clearTimeout(timeout);
42
42
 
43
- // Give aXe 60s (or user-supplied value) to respond to 'axe.start'
43
+ // Give axe 60s (or user-supplied value) to respond to 'axe.start'
44
44
  var frameWaitTime =
45
45
  (parameters.options && parameters.options.frameWaitTime) || 60000;
46
46
 
47
- timeout = setTimeout(function() {
47
+ timeout = setTimeout(function collectResultFramesTimeout() {
48
48
  reject(err('Axe in frame timed out', node));
49
49
  }, frameWaitTime);
50
50
 
@@ -2,29 +2,43 @@
2
2
  * Wrapper for Node#contains; PhantomJS does not support Node#contains and erroneously reports that it does
3
3
  * @method contains
4
4
  * @memberof axe.utils
5
- * @param {HTMLElement} node The candidate container node
6
- * @param {HTMLElement} otherNode The node to test is contained by `node`
7
- * @return {Boolean} Whether `node` contains `otherNode`
5
+ * @param {VirtualNode} vNode The candidate container VirtualNode
6
+ * @param {VirtualNode} otherVNode The vNode to test is contained by `vNode`
7
+ * @return {Boolean} Whether `vNode` contains `otherVNode`
8
8
  */
9
- axe.utils.contains = function(node, otherNode) {
9
+ axe.utils.contains = function(vNode, otherVNode) {
10
10
  /*eslint no-bitwise: 0*/
11
11
  'use strict';
12
- function containsShadowChild(node, otherNode) {
13
- if (node.shadowId === otherNode.shadowId) {
12
+ function containsShadowChild(vNode, otherVNode) {
13
+ if (vNode.shadowId === otherVNode.shadowId) {
14
14
  return true;
15
15
  }
16
- return !!node.children.find(child => {
17
- return containsShadowChild(child, otherNode);
16
+ return !!vNode.children.find(child => {
17
+ return containsShadowChild(child, otherVNode);
18
18
  });
19
19
  }
20
20
 
21
- if (node.shadowId || otherNode.shadowId) {
22
- return containsShadowChild(node, otherNode);
21
+ if (vNode.shadowId || otherVNode.shadowId) {
22
+ return containsShadowChild(vNode, otherVNode);
23
23
  }
24
24
 
25
- if (typeof node.actualNode.contains === 'function') {
26
- return node.actualNode.contains(otherNode.actualNode);
25
+ if (vNode.actualNode) {
26
+ if (typeof vNode.actualNode.contains === 'function') {
27
+ return vNode.actualNode.contains(otherVNode.actualNode);
28
+ }
29
+
30
+ return !!(
31
+ vNode.actualNode.compareDocumentPosition(otherVNode.actualNode) & 16
32
+ );
33
+ } else {
34
+ // fallback for virtualNode only contexts (e.g. linting)
35
+ // @see https://github.com/Financial-Times/polyfill-service/pull/183/files
36
+ do {
37
+ if (otherVNode === vNode) {
38
+ return true;
39
+ }
40
+ } while ((otherVNode = otherVNode && otherVNode.parent));
27
41
  }
28
42
 
29
- return !!(node.actualNode.compareDocumentPosition(otherNode.actualNode) & 16);
43
+ return false;
30
44
  };