govuk_publishing_components 21.16.3 → 21.17.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -26,13 +26,13 @@ axe.utils.shouldPreload = function shouldPreload(options) {
26
26
  /**
27
27
  * Constructs a configuration object representing the preload requested assets & timeout
28
28
  * @param {Object} options run configuration options (or defaults) passed via axe.run
29
- * @return {Object}
29
+ * @return {Object} configuration
30
30
  */
31
31
  axe.utils.getPreloadConfig = function getPreloadConfig(options) {
32
- // default fallback configuration
32
+ const { assets, timeout } = axe.constants.preload;
33
33
  const config = {
34
- assets: axe.constants.preloadAssets,
35
- timeout: axe.constants.preloadAssetsTimeout
34
+ assets,
35
+ timeout
36
36
  };
37
37
 
38
38
  // if no `preload` is configured via `options` - return default config
@@ -47,13 +47,13 @@ axe.utils.getPreloadConfig = function getPreloadConfig(options) {
47
47
 
48
48
  // check if requested assets to preload are valid items
49
49
  const areRequestedAssetsValid = options.preload.assets.every(a =>
50
- axe.constants.preloadAssets.includes(a.toLowerCase())
50
+ assets.includes(a.toLowerCase())
51
51
  );
52
52
 
53
53
  if (!areRequestedAssetsValid) {
54
54
  throw new Error(
55
55
  `Requested assets, not supported. ` +
56
- `Supported assets are: ${axe.constants.preloadAssets.join(', ')}.`
56
+ `Supported assets are: ${assets.join(', ')}.`
57
57
  );
58
58
  }
59
59
 
@@ -74,36 +74,62 @@ axe.utils.getPreloadConfig = function getPreloadConfig(options) {
74
74
  };
75
75
 
76
76
  /**
77
- * Returns a then(able) queue with results of all requested preload(able) assets. Eg: ['cssom'].
78
- * If preload is set to false, returns an empty queue.
77
+ * Returns a Promise with results of all requested preload(able) assets. eg: ['cssom'].
78
+ *
79
79
  * @param {Object} options run configuration options (or defaults) passed via axe.run
80
- * @return {Object} queue
80
+ * @return {Object} Promise
81
81
  */
82
82
  axe.utils.preload = function preload(options) {
83
83
  const preloadFunctionsMap = {
84
84
  cssom: axe.utils.preloadCssom
85
85
  };
86
86
 
87
- const q = axe.utils.queue();
88
-
89
87
  const shouldPreload = axe.utils.shouldPreload(options);
90
88
  if (!shouldPreload) {
91
- return q;
89
+ return Promise.resolve();
92
90
  }
93
91
 
94
- const preloadConfig = axe.utils.getPreloadConfig(options);
92
+ return new Promise((resolve, reject) => {
93
+ const { assets, timeout } = axe.utils.getPreloadConfig(options);
94
+
95
+ /**
96
+ * Start `timeout` timer for preloading assets
97
+ * -> reject if allowed time expires.
98
+ */
99
+ setTimeout(() => reject(`Preload assets timed out.`), timeout);
100
+
101
+ /**
102
+ * Fetch requested `assets`
103
+ */
95
104
 
96
- preloadConfig.assets.forEach(asset => {
97
- q.defer((resolve, reject) => {
98
- preloadFunctionsMap[asset](preloadConfig)
99
- .then(results => {
100
- resolve({
101
- [asset]: results[0]
102
- });
105
+ Promise.all(
106
+ assets.map(asset =>
107
+ preloadFunctionsMap[asset](options).then(results => {
108
+ return {
109
+ [asset]: results
110
+ };
103
111
  })
104
- .catch(reject);
112
+ )
113
+ ).then(results => {
114
+ /**
115
+ * Combine array of results into an object map
116
+ *
117
+ * From ->
118
+ * [{cssom: [...], aom: [...]}]
119
+ * To ->
120
+ * {
121
+ * cssom: [...]
122
+ * aom: [...]
123
+ * }
124
+ */
125
+ const preloadAssets = results.reduce((out, result) => {
126
+ return {
127
+ ...out,
128
+ ...result
129
+ };
130
+ }, {});
131
+
132
+ resolve(preloadAssets);
105
133
  });
106
134
  });
107
-
108
- return q;
109
135
  };
@@ -4,50 +4,42 @@ var matchExpressions = function() {};
4
4
 
5
5
  // todo: implement an option to follow aria-owns
6
6
 
7
- function matchesTag(node, exp) {
7
+ function matchesTag(vNode, exp) {
8
8
  return (
9
- node.nodeType === 1 &&
10
- (exp.tag === '*' || node.nodeName.toLowerCase() === exp.tag)
9
+ vNode.props.nodeType === 1 &&
10
+ (exp.tag === '*' || vNode.props.nodeName === exp.tag)
11
11
  );
12
12
  }
13
13
 
14
- function matchesClasses(node, exp) {
15
- return (
16
- !exp.classes ||
17
- exp.classes.reduce((result, cl) => {
18
- return result && (node.className && node.className.match(cl.regexp));
19
- }, true)
20
- );
14
+ function matchesClasses(vNode, exp) {
15
+ return !exp.classes || exp.classes.every(cl => vNode.hasClass(cl.value));
21
16
  }
22
17
 
23
- function matchesAttributes(node, exp) {
18
+ function matchesAttributes(vNode, exp) {
24
19
  return (
25
20
  !exp.attributes ||
26
- exp.attributes.reduce((result, att) => {
27
- var nodeAtt = node.getAttribute(att.key);
28
- return result && nodeAtt !== null && (!att.value || att.test(nodeAtt));
29
- }, true)
21
+ exp.attributes.every(att => {
22
+ var nodeAtt = vNode.attr(att.key);
23
+ return nodeAtt !== null && (!att.value || att.test(nodeAtt));
24
+ })
30
25
  );
31
26
  }
32
27
 
33
- function matchesId(node, exp) {
34
- return !exp.id || node.id === exp.id;
28
+ function matchesId(vNode, exp) {
29
+ return !exp.id || vNode.props.id === exp.id;
35
30
  }
36
31
 
37
32
  function matchesPseudos(target, exp) {
38
33
  if (
39
34
  !exp.pseudos ||
40
- exp.pseudos.reduce((result, pseudo) => {
35
+ exp.pseudos.every(pseudo => {
41
36
  if (pseudo.name === 'not') {
42
- return (
43
- result &&
44
- !matchExpressions([target], pseudo.expressions, false).length
45
- );
37
+ return !matchExpressions([target], pseudo.expressions, false).length;
46
38
  }
47
39
  throw new Error(
48
40
  'the pseudo selector ' + pseudo.name + ' has not yet been implemented'
49
41
  );
50
- }, true)
42
+ })
51
43
  ) {
52
44
  return true;
53
45
  }
@@ -66,13 +58,11 @@ var escapeRegExp = (function() {
66
58
  var reUnescape = /\\/g;
67
59
 
68
60
  function convertAttributes(atts) {
69
- /*eslint indent:0*/
70
61
  /*! Credit Mootools Copyright Mootools, MIT License */
71
62
  if (!atts) {
72
63
  return;
73
64
  }
74
65
  return atts.map(att => {
75
- // eslint complexity:["error", 13]
76
66
  var attributeKey = att.name.replace(reUnescape, '');
77
67
  var attributeValue = (att.value || '').replace(reUnescape, '');
78
68
  var test, regexp;
@@ -154,7 +144,7 @@ function convertPseudos(pseudos) {
154
144
  var expressions;
155
145
 
156
146
  if (p.name === 'not') {
157
- expressions = axe.utils.cssParser.parse(p.value);
147
+ expressions = p.value;
158
148
  expressions = expressions.selectors
159
149
  ? expressions.selectors
160
150
  : [expressions];
@@ -196,41 +186,40 @@ convertExpressions = function(expressions) {
196
186
  });
197
187
  };
198
188
 
199
- function createLocalVariables(nodes, anyLevel, thisLevel, parentShadowId) {
189
+ function createLocalVariables(vNodes, anyLevel, thisLevel, parentShadowId) {
200
190
  let retVal = {
201
- nodes: nodes.slice(),
191
+ vNodes: vNodes.slice(),
202
192
  anyLevel: anyLevel,
203
193
  thisLevel: thisLevel,
204
194
  parentShadowId: parentShadowId
205
195
  };
206
- retVal.nodes.reverse();
196
+ retVal.vNodes.reverse();
207
197
  return retVal;
208
198
  }
209
199
 
210
- function matchesSelector(node, exp) {
200
+ function matchesSelector(vNode, exp) {
211
201
  return (
212
- matchesTag(node.actualNode, exp[0]) &&
213
- matchesClasses(node.actualNode, exp[0]) &&
214
- matchesAttributes(node.actualNode, exp[0]) &&
215
- matchesId(node.actualNode, exp[0]) &&
216
- matchesPseudos(node, exp[0])
202
+ matchesTag(vNode, exp[0]) &&
203
+ matchesClasses(vNode, exp[0]) &&
204
+ matchesAttributes(vNode, exp[0]) &&
205
+ matchesId(vNode, exp[0]) &&
206
+ matchesPseudos(vNode, exp[0])
217
207
  );
218
208
  }
219
209
 
220
210
  matchExpressions = function(domTree, expressions, recurse, filter) {
221
- /*eslint max-statements:["error", 34], complexity:["error", 22]*/
222
211
  let stack = [];
223
- let nodes = Array.isArray(domTree) ? domTree : [domTree];
212
+ let vNodes = Array.isArray(domTree) ? domTree : [domTree];
224
213
  let currentLevel = createLocalVariables(
225
- nodes,
214
+ vNodes,
226
215
  expressions,
227
216
  [],
228
217
  domTree[0].shadowId
229
218
  );
230
219
  let result = [];
231
220
 
232
- while (currentLevel.nodes.length) {
233
- let node = currentLevel.nodes.pop();
221
+ while (currentLevel.vNodes.length) {
222
+ let vNode = currentLevel.vNodes.pop();
234
223
  let childOnly = []; // we will add hierarchical '>' selectors here
235
224
  let childAny = [];
236
225
  let combined = currentLevel.anyLevel.slice().concat(currentLevel.thisLevel);
@@ -239,12 +228,12 @@ matchExpressions = function(domTree, expressions, recurse, filter) {
239
228
  for (let i = 0; i < combined.length; i++) {
240
229
  let exp = combined[i];
241
230
  if (
242
- matchesSelector(node, exp) &&
243
- (!exp[0].id || node.shadowId === currentLevel.parentShadowId)
231
+ (!exp[0].id || vNode.shadowId === currentLevel.parentShadowId) &&
232
+ matchesSelector(vNode, exp)
244
233
  ) {
245
234
  if (exp.length === 1) {
246
- if (!added && (!filter || filter(node))) {
247
- result.push(node);
235
+ if (!added && (!filter || filter(vNode))) {
236
+ result.push(vNode);
248
237
  added = true;
249
238
  }
250
239
  } else {
@@ -265,24 +254,24 @@ matchExpressions = function(domTree, expressions, recurse, filter) {
265
254
  }
266
255
  }
267
256
  if (
268
- currentLevel.anyLevel.includes(exp) &&
269
- (!exp[0].id || node.shadowId === currentLevel.parentShadowId)
257
+ (!exp[0].id || vNode.shadowId === currentLevel.parentShadowId) &&
258
+ currentLevel.anyLevel.includes(exp)
270
259
  ) {
271
260
  childAny.push(exp);
272
261
  }
273
262
  }
274
263
  // "recurse"
275
- if (node.children && node.children.length && recurse) {
264
+ if (vNode.children && vNode.children.length && recurse) {
276
265
  stack.push(currentLevel);
277
266
  currentLevel = createLocalVariables(
278
- node.children,
267
+ vNode.children,
279
268
  childAny,
280
269
  childOnly,
281
- node.shadowId
270
+ vNode.shadowId
282
271
  );
283
272
  }
284
273
  // check for "return"
285
- while (!currentLevel.nodes.length && stack.length) {
274
+ while (!currentLevel.vNodes.length && stack.length) {
286
275
  currentLevel = stack.pop();
287
276
  }
288
277
  }
@@ -13,7 +13,7 @@
13
13
  ]);
14
14
 
15
15
  /**
16
- * get the unique string to be used to identify our instance of aXe
16
+ * get the unique string to be used to identify our instance of axe
17
17
  * @private
18
18
  */
19
19
  function _getSource() {
@@ -86,6 +86,12 @@
86
86
  _keepalive: keepalive
87
87
  };
88
88
 
89
+ var axeRespondables = axe._cache.get('axeRespondables');
90
+ if (!axeRespondables) {
91
+ axeRespondables = {};
92
+ axe._cache.set('axeRespondables', axeRespondables);
93
+ }
94
+ axeRespondables[uuid] = true;
89
95
  if (typeof callback === 'function') {
90
96
  messages[uuid] = callback;
91
97
  }
@@ -206,7 +212,6 @@
206
212
  window.addEventListener(
207
213
  'message',
208
214
  function(e) {
209
- /* eslint max-statements: ["error", 20]*/
210
215
  var data = parseMessage(e.data);
211
216
  if (!data) {
212
217
  return;
@@ -214,6 +219,18 @@
214
219
 
215
220
  var uuid = data.uuid;
216
221
 
222
+ /**
223
+ * NOTE: messages from other contexts (frames) in response
224
+ * to a message should not contain a topic. We ignore these
225
+ * messages to prevent rogue postMessage handlers reflecting
226
+ * our messages.
227
+ * @see https://github.com/dequelabs/axe-core/issues/1754
228
+ */
229
+ var axeRespondables = axe._cache.get('axeRespondables') || {};
230
+ if (axeRespondables[uuid] && data.topic && e.source !== window) {
231
+ return;
232
+ }
233
+
217
234
  var keepalive = data._keepalive;
218
235
  var callback = messages[uuid];
219
236
 
@@ -231,7 +248,7 @@
231
248
  try {
232
249
  publish(e.source, data, keepalive);
233
250
  } catch (err) {
234
- post(e.source, data.topic, err, uuid, false);
251
+ post(e.source, null, err, uuid, false);
235
252
  }
236
253
  }
237
254
  },
@@ -5,7 +5,6 @@
5
5
  * @param {object} runOnly Value of runOnly with type=tags
6
6
  * @return {bool}
7
7
  */
8
- /* eslint complexity: ["error", 14]*/
9
8
  function matchTags(rule, runOnly) {
10
9
  'use strict';
11
10
  var include, exclude, matching;
@@ -1,26 +1,9 @@
1
- /**
2
- * Return the scroll position of scrollable elements
3
- */
4
- function getScroll(elm) {
5
- const style = window.getComputedStyle(elm);
6
- const visibleOverflowY = style.getPropertyValue('overflow-y') === 'visible';
7
- const visibleOverflowX = style.getPropertyValue('overflow-x') === 'visible';
8
-
9
- if (
10
- // See if the element hides overflowing content
11
- (!visibleOverflowY && elm.scrollHeight > elm.clientHeight) ||
12
- (!visibleOverflowX && elm.scrollWidth > elm.clientWidth)
13
- ) {
14
- return { elm, top: elm.scrollTop, left: elm.scrollLeft };
15
- }
16
- }
17
-
18
1
  /**
19
2
  * set the scroll position of an element
20
3
  */
21
4
  function setScroll(elm, top, left) {
22
5
  if (elm === window) {
23
- return elm.scroll(top, left);
6
+ return elm.scroll(left, top);
24
7
  } else {
25
8
  elm.scrollTop = top;
26
9
  elm.scrollLeft = left;
@@ -31,13 +14,17 @@ function setScroll(elm, top, left) {
31
14
  * Create an array scroll positions from descending elements
32
15
  */
33
16
  function getElmScrollRecursive(root) {
34
- return Array.from(root.children).reduce((scrolls, elm) => {
35
- const scroll = getScroll(elm);
36
- if (scroll) {
37
- scrolls.push(scroll);
38
- }
39
- return scrolls.concat(getElmScrollRecursive(elm));
40
- }, []);
17
+ // Need to also get .childNodes since SVGs in IE don't have .children.
18
+ return Array.from(root.children || root.childNodes || []).reduce(
19
+ (scrolls, elm) => {
20
+ const scroll = axe.utils.getScroll(elm);
21
+ if (scroll) {
22
+ scrolls.push(scroll);
23
+ }
24
+ return scrolls.concat(getElmScrollRecursive(elm));
25
+ },
26
+ []
27
+ );
41
28
  }
42
29
 
43
30
  /**
@@ -25,14 +25,14 @@ function getDeepest(collection) {
25
25
  function isNodeInContext(node, context) {
26
26
  'use strict';
27
27
 
28
- var include =
28
+ const include =
29
29
  context.include &&
30
30
  getDeepest(
31
31
  context.include.filter(function(candidate) {
32
32
  return axe.utils.contains(candidate, node);
33
33
  })
34
34
  );
35
- var exclude =
35
+ const exclude =
36
36
  context.exclude &&
37
37
  getDeepest(
38
38
  context.exclude.filter(function(candidate) {
@@ -58,7 +58,7 @@ function isNodeInContext(node, context) {
58
58
  function pushNode(result, nodes) {
59
59
  'use strict';
60
60
 
61
- var temp;
61
+ let temp;
62
62
 
63
63
  if (result.length === 0) {
64
64
  return nodes;
@@ -69,7 +69,7 @@ function pushNode(result, nodes) {
69
69
  result = nodes;
70
70
  nodes = temp;
71
71
  }
72
- for (var i = 0, l = nodes.length; i < l; i++) {
72
+ for (let i = 0, l = nodes.length; i < l; i++) {
73
73
  if (!result.includes(nodes[i])) {
74
74
  result.push(nodes[i]);
75
75
  }
@@ -84,10 +84,7 @@ function pushNode(result, nodes) {
84
84
  */
85
85
  function reduceIncludes(includes) {
86
86
  return includes.reduce((res, el) => {
87
- if (
88
- !res.length ||
89
- !res[res.length - 1].actualNode.contains(el.actualNode)
90
- ) {
87
+ if (!res.length || !axe.utils.contains(res[res.length - 1], el)) {
91
88
  res.push(el);
92
89
  }
93
90
  return res;
@@ -100,37 +97,29 @@ function reduceIncludes(includes) {
100
97
  * @param {Context} context The "resolved" context object, @see Context
101
98
  * @return {Array} Matching virtual DOM nodes sorted by DOM order
102
99
  */
103
- /*eslint max-statements:["error", 20]*/
104
100
  axe.utils.select = function select(selector, context) {
105
101
  'use strict';
106
102
 
107
- var result = [],
108
- candidate;
103
+ let result = [];
104
+ let candidate;
109
105
  if (axe._selectCache) {
110
106
  // if used outside of run, it will still work
111
- for (var j = 0, l = axe._selectCache.length; j < l; j++) {
107
+ for (let j = 0, l = axe._selectCache.length; j < l; j++) {
112
108
  // First see whether the item exists in the cache
113
- let item = axe._selectCache[j];
109
+ const item = axe._selectCache[j];
114
110
  if (item.selector === selector) {
115
111
  return item.result;
116
112
  }
117
113
  }
118
114
  }
119
- var curried = (function(context) {
115
+ const curried = (function(context) {
120
116
  return function(node) {
121
117
  return isNodeInContext(node, context);
122
118
  };
123
119
  })(context);
124
- var reducedIncludes = reduceIncludes(context.include);
125
- for (var i = 0; i < reducedIncludes.length; i++) {
120
+ const reducedIncludes = reduceIncludes(context.include);
121
+ for (let i = 0; i < reducedIncludes.length; i++) {
126
122
  candidate = reducedIncludes[i];
127
- if (
128
- candidate.actualNode.nodeType === candidate.actualNode.ELEMENT_NODE &&
129
- axe.utils.matchesSelector(candidate.actualNode, selector) &&
130
- curried(candidate)
131
- ) {
132
- result = pushNode(result, [candidate]);
133
- }
134
123
  result = pushNode(
135
124
  result,
136
125
  axe.utils.querySelectorAllFilter(candidate, selector, curried)