govuk_publishing_components 16.6.0 → 16.7.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 (531) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/component_guide/accessibility-test.js +6 -12
  3. data/app/assets/javascripts/component_guide/vendor/bind-polyfill.js +8 -0
  4. data/app/assets/javascripts/govuk_publishing_components/lib/toggle.js +16 -0
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_fieldset.scss +1 -27
  6. data/app/views/govuk_publishing_components/components/_fieldset.html.erb +2 -2
  7. data/app/views/govuk_publishing_components/components/_input.html.erb +2 -0
  8. data/app/views/govuk_publishing_components/components/docs/input.yml +7 -0
  9. data/lib/govuk_publishing_components/version.rb +1 -1
  10. data/node_modules/accessible-autocomplete/package.json +1 -1
  11. data/node_modules/axe-core/CHANGELOG.md +741 -0
  12. data/node_modules/axe-core/CONTRIBUTING.md +187 -0
  13. data/node_modules/axe-core/LICENSE +362 -0
  14. data/node_modules/axe-core/README.md +147 -0
  15. data/node_modules/axe-core/axe.d.ts +216 -0
  16. data/node_modules/axe-core/axe.js +15298 -0
  17. data/node_modules/axe-core/axe.min.js +12 -0
  18. data/node_modules/axe-core/bower.json +40 -0
  19. data/node_modules/axe-core/doc/API.md +798 -0
  20. data/node_modules/axe-core/doc/accessibility-supported.md +33 -0
  21. data/node_modules/axe-core/doc/act-rules-format.md +37 -0
  22. data/node_modules/axe-core/doc/aria-supported.md +23 -0
  23. data/node_modules/axe-core/doc/axelogo2018.png +0 -0
  24. data/node_modules/axe-core/doc/code-submission-guidelines.md +178 -0
  25. data/node_modules/axe-core/doc/developer-guide.md +500 -0
  26. data/node_modules/axe-core/doc/examples/chrome-debugging-protocol/README.md +13 -0
  27. data/node_modules/axe-core/doc/examples/chrome-debugging-protocol/axe-cdp.js +81 -0
  28. data/node_modules/axe-core/doc/examples/chrome-debugging-protocol/package.json +8 -0
  29. data/node_modules/axe-core/doc/examples/html-handlebars.md +164 -0
  30. data/node_modules/axe-core/doc/examples/jasmine/README.md +37 -0
  31. data/node_modules/axe-core/doc/examples/jasmine/package.json +20 -0
  32. data/node_modules/axe-core/doc/examples/jasmine/spec/a11y.js +36 -0
  33. data/node_modules/axe-core/doc/examples/jest_react/README.md +41 -0
  34. data/node_modules/axe-core/doc/examples/jest_react/link.js +7 -0
  35. data/node_modules/axe-core/doc/examples/jest_react/link.test.js +24 -0
  36. data/node_modules/axe-core/doc/examples/jest_react/package.json +28 -0
  37. data/node_modules/axe-core/doc/examples/jest_react/test-helpers.js +21 -0
  38. data/node_modules/axe-core/doc/examples/mocha/README.md +37 -0
  39. data/node_modules/axe-core/doc/examples/mocha/package.json +21 -0
  40. data/node_modules/axe-core/doc/examples/phantomjs/README.md +17 -0
  41. data/node_modules/axe-core/doc/examples/phantomjs/axe-phantom.js +51 -0
  42. data/node_modules/axe-core/doc/examples/phantomjs/package.json +19 -0
  43. data/node_modules/axe-core/doc/examples/puppeteer/README.md +12 -0
  44. data/node_modules/axe-core/doc/examples/puppeteer/axe-puppeteer.js +60 -0
  45. data/node_modules/axe-core/doc/examples/puppeteer/package.json +10 -0
  46. data/node_modules/axe-core/doc/examples/qunit/README.md +37 -0
  47. data/node_modules/axe-core/doc/examples/qunit/package.json +21 -0
  48. data/node_modules/axe-core/doc/plugins.md +123 -0
  49. data/node_modules/axe-core/doc/projects.md +44 -0
  50. data/node_modules/axe-core/doc/rule-descriptions.md +79 -0
  51. data/node_modules/axe-core/doc/rule-development.md +95 -0
  52. data/node_modules/axe-core/doc/rule-proposal.md +106 -0
  53. data/node_modules/axe-core/lib/checks/aria/abstractrole.js +1 -0
  54. data/node_modules/axe-core/lib/checks/aria/abstractrole.json +11 -0
  55. data/node_modules/axe-core/lib/checks/aria/allowed-attr.js +39 -0
  56. data/node_modules/axe-core/lib/checks/aria/allowed-attr.json +11 -0
  57. data/node_modules/axe-core/lib/checks/aria/aria-allowed-role.js +28 -0
  58. data/node_modules/axe-core/lib/checks/aria/aria-allowed-role.json +16 -0
  59. data/node_modules/axe-core/lib/checks/aria/aria-hidden-body.js +1 -0
  60. data/node_modules/axe-core/lib/checks/aria/aria-hidden-body.json +11 -0
  61. data/node_modules/axe-core/lib/checks/aria/errormessage.js +33 -0
  62. data/node_modules/axe-core/lib/checks/aria/errormessage.json +11 -0
  63. data/node_modules/axe-core/lib/checks/aria/has-widget-role.js +6 -0
  64. data/node_modules/axe-core/lib/checks/aria/has-widget-role.json +12 -0
  65. data/node_modules/axe-core/lib/checks/aria/implicit-role-fallback.js +6 -0
  66. data/node_modules/axe-core/lib/checks/aria/implicit-role-fallback.json +11 -0
  67. data/node_modules/axe-core/lib/checks/aria/invalidrole.js +3 -0
  68. data/node_modules/axe-core/lib/checks/aria/invalidrole.json +11 -0
  69. data/node_modules/axe-core/lib/checks/aria/required-attr.js +28 -0
  70. data/node_modules/axe-core/lib/checks/aria/required-attr.json +11 -0
  71. data/node_modules/axe-core/lib/checks/aria/required-children.js +117 -0
  72. data/node_modules/axe-core/lib/checks/aria/required-children.json +15 -0
  73. data/node_modules/axe-core/lib/checks/aria/required-parent.js +87 -0
  74. data/node_modules/axe-core/lib/checks/aria/required-parent.json +11 -0
  75. data/node_modules/axe-core/lib/checks/aria/unsupportedattr.js +39 -0
  76. data/node_modules/axe-core/lib/checks/aria/unsupportedattr.json +11 -0
  77. data/node_modules/axe-core/lib/checks/aria/unsupportedrole.js +1 -0
  78. data/node_modules/axe-core/lib/checks/aria/unsupportedrole.json +11 -0
  79. data/node_modules/axe-core/lib/checks/aria/valid-attr-value.js +32 -0
  80. data/node_modules/axe-core/lib/checks/aria/valid-attr-value.json +12 -0
  81. data/node_modules/axe-core/lib/checks/aria/valid-attr.js +25 -0
  82. data/node_modules/axe-core/lib/checks/aria/valid-attr.json +12 -0
  83. data/node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js +62 -0
  84. data/node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.json +12 -0
  85. data/node_modules/axe-core/lib/checks/color/color-contrast.js +70 -0
  86. data/node_modules/axe-core/lib/checks/color/color-contrast.json +24 -0
  87. data/node_modules/axe-core/lib/checks/color/link-in-text-block.js +85 -0
  88. data/node_modules/axe-core/lib/checks/color/link-in-text-block.json +19 -0
  89. data/node_modules/axe-core/lib/checks/forms/autocomplete-appropriate.js +67 -0
  90. data/node_modules/axe-core/lib/checks/forms/autocomplete-appropriate.json +11 -0
  91. data/node_modules/axe-core/lib/checks/forms/autocomplete-valid.js +2 -0
  92. data/node_modules/axe-core/lib/checks/forms/autocomplete-valid.json +11 -0
  93. data/node_modules/axe-core/lib/checks/forms/fieldset-after.js +25 -0
  94. data/node_modules/axe-core/lib/checks/forms/fieldset.js +109 -0
  95. data/node_modules/axe-core/lib/checks/forms/fieldset.json +12 -0
  96. data/node_modules/axe-core/lib/checks/forms/group-labelledby-after.js +16 -0
  97. data/node_modules/axe-core/lib/checks/forms/group-labelledby.js +66 -0
  98. data/node_modules/axe-core/lib/checks/forms/group-labelledby.json +12 -0
  99. data/node_modules/axe-core/lib/checks/keyboard/accesskeys-after.js +19 -0
  100. data/node_modules/axe-core/lib/checks/keyboard/accesskeys.js +5 -0
  101. data/node_modules/axe-core/lib/checks/keyboard/accesskeys.json +12 -0
  102. data/node_modules/axe-core/lib/checks/keyboard/focusable-disabled.js +25 -0
  103. data/node_modules/axe-core/lib/checks/keyboard/focusable-disabled.json +11 -0
  104. data/node_modules/axe-core/lib/checks/keyboard/focusable-no-name.js +6 -0
  105. data/node_modules/axe-core/lib/checks/keyboard/focusable-no-name.json +11 -0
  106. data/node_modules/axe-core/lib/checks/keyboard/focusable-not-tabbable.js +25 -0
  107. data/node_modules/axe-core/lib/checks/keyboard/focusable-not-tabbable.json +11 -0
  108. data/node_modules/axe-core/lib/checks/keyboard/landmark-is-top-level.js +18 -0
  109. data/node_modules/axe-core/lib/checks/keyboard/landmark-is-top-level.json +11 -0
  110. data/node_modules/axe-core/lib/checks/keyboard/page-has-elm-after.js +11 -0
  111. data/node_modules/axe-core/lib/checks/keyboard/page-has-elm.js +9 -0
  112. data/node_modules/axe-core/lib/checks/keyboard/page-has-heading-one.json +15 -0
  113. data/node_modules/axe-core/lib/checks/keyboard/page-has-main.json +15 -0
  114. data/node_modules/axe-core/lib/checks/keyboard/page-no-duplicate-banner.json +15 -0
  115. data/node_modules/axe-core/lib/checks/keyboard/page-no-duplicate-contentinfo.json +15 -0
  116. data/node_modules/axe-core/lib/checks/keyboard/page-no-duplicate-main.json +14 -0
  117. data/node_modules/axe-core/lib/checks/keyboard/page-no-duplicate.js +22 -0
  118. data/node_modules/axe-core/lib/checks/keyboard/tabindex.js +1 -0
  119. data/node_modules/axe-core/lib/checks/keyboard/tabindex.json +11 -0
  120. data/node_modules/axe-core/lib/checks/label/alt-space-value.js +2 -0
  121. data/node_modules/axe-core/lib/checks/label/alt-space-value.json +11 -0
  122. data/node_modules/axe-core/lib/checks/label/duplicate-img-label.js +19 -0
  123. data/node_modules/axe-core/lib/checks/label/duplicate-img-label.json +11 -0
  124. data/node_modules/axe-core/lib/checks/label/explicit.js +15 -0
  125. data/node_modules/axe-core/lib/checks/label/explicit.json +11 -0
  126. data/node_modules/axe-core/lib/checks/label/help-same-as-label.js +23 -0
  127. data/node_modules/axe-core/lib/checks/label/help-same-as-label.json +12 -0
  128. data/node_modules/axe-core/lib/checks/label/hidden-explicit-label.js +12 -0
  129. data/node_modules/axe-core/lib/checks/label/hidden-explicit-label.json +11 -0
  130. data/node_modules/axe-core/lib/checks/label/implicit.js +7 -0
  131. data/node_modules/axe-core/lib/checks/label/implicit.json +11 -0
  132. data/node_modules/axe-core/lib/checks/label/label-content-name-mismatch.js +49 -0
  133. data/node_modules/axe-core/lib/checks/label/label-content-name-mismatch.json +11 -0
  134. data/node_modules/axe-core/lib/checks/label/multiple-label.js +29 -0
  135. data/node_modules/axe-core/lib/checks/label/multiple-label.json +11 -0
  136. data/node_modules/axe-core/lib/checks/label/title-only.js +5 -0
  137. data/node_modules/axe-core/lib/checks/label/title-only.json +11 -0
  138. data/node_modules/axe-core/lib/checks/language/has-lang.js +5 -0
  139. data/node_modules/axe-core/lib/checks/language/has-lang.json +11 -0
  140. data/node_modules/axe-core/lib/checks/language/valid-lang.js +26 -0
  141. data/node_modules/axe-core/lib/checks/language/valid-lang.json +11 -0
  142. data/node_modules/axe-core/lib/checks/language/xml-lang-mismatch.js +5 -0
  143. data/node_modules/axe-core/lib/checks/language/xml-lang-mismatch.json +11 -0
  144. data/node_modules/axe-core/lib/checks/lists/dlitem.js +23 -0
  145. data/node_modules/axe-core/lib/checks/lists/dlitem.json +11 -0
  146. data/node_modules/axe-core/lib/checks/lists/listitem.js +18 -0
  147. data/node_modules/axe-core/lib/checks/lists/listitem.json +11 -0
  148. data/node_modules/axe-core/lib/checks/lists/only-dlitems.js +42 -0
  149. data/node_modules/axe-core/lib/checks/lists/only-dlitems.json +11 -0
  150. data/node_modules/axe-core/lib/checks/lists/only-listitems.js +68 -0
  151. data/node_modules/axe-core/lib/checks/lists/only-listitems.json +11 -0
  152. data/node_modules/axe-core/lib/checks/lists/structured-dlitems.js +22 -0
  153. data/node_modules/axe-core/lib/checks/lists/structured-dlitems.json +11 -0
  154. data/node_modules/axe-core/lib/checks/media/caption.js +8 -0
  155. data/node_modules/axe-core/lib/checks/media/caption.json +11 -0
  156. data/node_modules/axe-core/lib/checks/media/description.js +8 -0
  157. data/node_modules/axe-core/lib/checks/media/description.json +11 -0
  158. data/node_modules/axe-core/lib/checks/media/frame-tested.js +28 -0
  159. data/node_modules/axe-core/lib/checks/media/frame-tested.json +15 -0
  160. data/node_modules/axe-core/lib/checks/mobile/css-orientation-lock.js +132 -0
  161. data/node_modules/axe-core/lib/checks/mobile/css-orientation-lock.json +12 -0
  162. data/node_modules/axe-core/lib/checks/mobile/meta-viewport-large.json +15 -0
  163. data/node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js +38 -0
  164. data/node_modules/axe-core/lib/checks/mobile/meta-viewport.json +14 -0
  165. data/node_modules/axe-core/lib/checks/navigation/header-present.js +4 -0
  166. data/node_modules/axe-core/lib/checks/navigation/header-present.json +11 -0
  167. data/node_modules/axe-core/lib/checks/navigation/heading-order-after.js +14 -0
  168. data/node_modules/axe-core/lib/checks/navigation/heading-order.js +15 -0
  169. data/node_modules/axe-core/lib/checks/navigation/heading-order.json +12 -0
  170. data/node_modules/axe-core/lib/checks/navigation/internal-link-present.js +4 -0
  171. data/node_modules/axe-core/lib/checks/navigation/internal-link-present.json +11 -0
  172. data/node_modules/axe-core/lib/checks/navigation/landmark.js +3 -0
  173. data/node_modules/axe-core/lib/checks/navigation/landmark.json +11 -0
  174. data/node_modules/axe-core/lib/checks/navigation/meta-refresh.js +4 -0
  175. data/node_modules/axe-core/lib/checks/navigation/meta-refresh.json +11 -0
  176. data/node_modules/axe-core/lib/checks/navigation/p-as-heading.js +93 -0
  177. data/node_modules/axe-core/lib/checks/navigation/p-as-heading.json +30 -0
  178. data/node_modules/axe-core/lib/checks/navigation/region-after.js +1 -0
  179. data/node_modules/axe-core/lib/checks/navigation/region.js +85 -0
  180. data/node_modules/axe-core/lib/checks/navigation/region.json +12 -0
  181. data/node_modules/axe-core/lib/checks/navigation/skip-link.js +5 -0
  182. data/node_modules/axe-core/lib/checks/navigation/skip-link.json +12 -0
  183. data/node_modules/axe-core/lib/checks/navigation/unique-frame-title-after.js +9 -0
  184. data/node_modules/axe-core/lib/checks/navigation/unique-frame-title.js +6 -0
  185. data/node_modules/axe-core/lib/checks/navigation/unique-frame-title.json +12 -0
  186. data/node_modules/axe-core/lib/checks/parsing/duplicate-id-active.json +12 -0
  187. data/node_modules/axe-core/lib/checks/parsing/duplicate-id-after.js +8 -0
  188. data/node_modules/axe-core/lib/checks/parsing/duplicate-id-aria.json +12 -0
  189. data/node_modules/axe-core/lib/checks/parsing/duplicate-id.js +17 -0
  190. data/node_modules/axe-core/lib/checks/parsing/duplicate-id.json +12 -0
  191. data/node_modules/axe-core/lib/checks/shared/aria-label.js +2 -0
  192. data/node_modules/axe-core/lib/checks/shared/aria-label.json +11 -0
  193. data/node_modules/axe-core/lib/checks/shared/aria-labelledby.js +2 -0
  194. data/node_modules/axe-core/lib/checks/shared/aria-labelledby.json +11 -0
  195. data/node_modules/axe-core/lib/checks/shared/button-has-visible-text.js +12 -0
  196. data/node_modules/axe-core/lib/checks/shared/button-has-visible-text.json +11 -0
  197. data/node_modules/axe-core/lib/checks/shared/doc-has-title.js +2 -0
  198. data/node_modules/axe-core/lib/checks/shared/doc-has-title.json +11 -0
  199. data/node_modules/axe-core/lib/checks/shared/exists.js +1 -0
  200. data/node_modules/axe-core/lib/checks/shared/exists.json +11 -0
  201. data/node_modules/axe-core/lib/checks/shared/has-alt.js +4 -0
  202. data/node_modules/axe-core/lib/checks/shared/has-alt.json +11 -0
  203. data/node_modules/axe-core/lib/checks/shared/has-visible-text.js +1 -0
  204. data/node_modules/axe-core/lib/checks/shared/has-visible-text.json +11 -0
  205. data/node_modules/axe-core/lib/checks/shared/is-on-screen.js +4 -0
  206. data/node_modules/axe-core/lib/checks/shared/is-on-screen.json +11 -0
  207. data/node_modules/axe-core/lib/checks/shared/non-empty-alt.js +2 -0
  208. data/node_modules/axe-core/lib/checks/shared/non-empty-alt.json +11 -0
  209. data/node_modules/axe-core/lib/checks/shared/non-empty-if-present.js +11 -0
  210. data/node_modules/axe-core/lib/checks/shared/non-empty-if-present.json +11 -0
  211. data/node_modules/axe-core/lib/checks/shared/non-empty-title.js +2 -0
  212. data/node_modules/axe-core/lib/checks/shared/non-empty-title.json +11 -0
  213. data/node_modules/axe-core/lib/checks/shared/non-empty-value.js +2 -0
  214. data/node_modules/axe-core/lib/checks/shared/non-empty-value.json +11 -0
  215. data/node_modules/axe-core/lib/checks/shared/role-none.js +1 -0
  216. data/node_modules/axe-core/lib/checks/shared/role-none.json +11 -0
  217. data/node_modules/axe-core/lib/checks/shared/role-presentation.js +1 -0
  218. data/node_modules/axe-core/lib/checks/shared/role-presentation.json +11 -0
  219. data/node_modules/axe-core/lib/checks/tables/caption-faked.js +10 -0
  220. data/node_modules/axe-core/lib/checks/tables/caption-faked.json +11 -0
  221. data/node_modules/axe-core/lib/checks/tables/has-caption.js +1 -0
  222. data/node_modules/axe-core/lib/checks/tables/has-caption.json +11 -0
  223. data/node_modules/axe-core/lib/checks/tables/has-summary.js +1 -0
  224. data/node_modules/axe-core/lib/checks/tables/has-summary.json +11 -0
  225. data/node_modules/axe-core/lib/checks/tables/has-th.js +31 -0
  226. data/node_modules/axe-core/lib/checks/tables/has-th.json +11 -0
  227. data/node_modules/axe-core/lib/checks/tables/headers-visible-text.js +30 -0
  228. data/node_modules/axe-core/lib/checks/tables/html5-scope.js +5 -0
  229. data/node_modules/axe-core/lib/checks/tables/html5-scope.json +11 -0
  230. data/node_modules/axe-core/lib/checks/tables/same-caption-summary.js +7 -0
  231. data/node_modules/axe-core/lib/checks/tables/same-caption-summary.json +11 -0
  232. data/node_modules/axe-core/lib/checks/tables/scope-value.js +5 -0
  233. data/node_modules/axe-core/lib/checks/tables/scope-value.json +11 -0
  234. data/node_modules/axe-core/lib/checks/tables/td-has-header.js +29 -0
  235. data/node_modules/axe-core/lib/checks/tables/td-has-header.json +11 -0
  236. data/node_modules/axe-core/lib/checks/tables/td-headers-attr.js +62 -0
  237. data/node_modules/axe-core/lib/checks/tables/td-headers-attr.json +11 -0
  238. data/node_modules/axe-core/lib/checks/tables/th-has-data-cells.js +76 -0
  239. data/node_modules/axe-core/lib/checks/tables/th-has-data-cells.json +12 -0
  240. data/node_modules/axe-core/lib/checks/tables/th-single-row-column.js +39 -0
  241. data/node_modules/axe-core/lib/checks/visibility/hidden-content.js +21 -0
  242. data/node_modules/axe-core/lib/checks/visibility/hidden-content.json +12 -0
  243. data/node_modules/axe-core/lib/commons/aria/arialabel-text.js +15 -0
  244. data/node_modules/axe-core/lib/commons/aria/arialabelledby-text.js +52 -0
  245. data/node_modules/axe-core/lib/commons/aria/attributes.js +45 -0
  246. data/node_modules/axe-core/lib/commons/aria/get-element-unallowed-roles.js +92 -0
  247. data/node_modules/axe-core/lib/commons/aria/get-owned-virtual.js +24 -0
  248. data/node_modules/axe-core/lib/commons/aria/get-role.js +44 -0
  249. data/node_modules/axe-core/lib/commons/aria/index.js +2417 -0
  250. data/node_modules/axe-core/lib/commons/aria/is-accessible-ref.js +55 -0
  251. data/node_modules/axe-core/lib/commons/aria/is-aria-role-allowed-on-element.js +41 -0
  252. data/node_modules/axe-core/lib/commons/aria/is-unsupported-role.js +14 -0
  253. data/node_modules/axe-core/lib/commons/aria/label-virtual.js +54 -0
  254. data/node_modules/axe-core/lib/commons/aria/named-from-contents.js +39 -0
  255. data/node_modules/axe-core/lib/commons/aria/roles.js +208 -0
  256. data/node_modules/axe-core/lib/commons/aria/validate-attr-value.js +63 -0
  257. data/node_modules/axe-core/lib/commons/color/contrast.js +172 -0
  258. data/node_modules/axe-core/lib/commons/color/element-is-distinct.js +88 -0
  259. data/node_modules/axe-core/lib/commons/color/get-background-color.js +411 -0
  260. data/node_modules/axe-core/lib/commons/color/get-foreground-color.js +32 -0
  261. data/node_modules/axe-core/lib/commons/color/incomplete-data.js +50 -0
  262. data/node_modules/axe-core/lib/commons/color/index.js +8 -0
  263. data/node_modules/axe-core/lib/commons/dom/elements-below-floating.js +39 -0
  264. data/node_modules/axe-core/lib/commons/dom/find-elms-in-context.js +28 -0
  265. data/node_modules/axe-core/lib/commons/dom/find-up.js +63 -0
  266. data/node_modules/axe-core/lib/commons/dom/get-composed-parent.js +25 -0
  267. data/node_modules/axe-core/lib/commons/dom/get-element-by-reference.js +34 -0
  268. data/node_modules/axe-core/lib/commons/dom/get-element-coordinates.js +38 -0
  269. data/node_modules/axe-core/lib/commons/dom/get-root-node.js +12 -0
  270. data/node_modules/axe-core/lib/commons/dom/get-scroll-offset.js +34 -0
  271. data/node_modules/axe-core/lib/commons/dom/get-tabbable-elements.js +24 -0
  272. data/node_modules/axe-core/lib/commons/dom/get-viewport-size.js +37 -0
  273. data/node_modules/axe-core/lib/commons/dom/has-content-virtual.js +73 -0
  274. data/node_modules/axe-core/lib/commons/dom/idrefs.js +36 -0
  275. data/node_modules/axe-core/lib/commons/dom/index.js +9 -0
  276. data/node_modules/axe-core/lib/commons/dom/is-focusable.js +90 -0
  277. data/node_modules/axe-core/lib/commons/dom/is-hidden-with-css.js +60 -0
  278. data/node_modules/axe-core/lib/commons/dom/is-html5.js +17 -0
  279. data/node_modules/axe-core/lib/commons/dom/is-in-text-block.js +95 -0
  280. data/node_modules/axe-core/lib/commons/dom/is-node.js +13 -0
  281. data/node_modules/axe-core/lib/commons/dom/is-offscreen.js +62 -0
  282. data/node_modules/axe-core/lib/commons/dom/is-visible.js +77 -0
  283. data/node_modules/axe-core/lib/commons/dom/is-visual-content.js +50 -0
  284. data/node_modules/axe-core/lib/commons/dom/shadow-elements-from-point.js +41 -0
  285. data/node_modules/axe-core/lib/commons/dom/visually-contains.js +62 -0
  286. data/node_modules/axe-core/lib/commons/dom/visually-overlaps.js +47 -0
  287. data/node_modules/axe-core/lib/commons/index.js +11 -0
  288. data/node_modules/axe-core/lib/commons/intro.stub +1 -0
  289. data/node_modules/axe-core/lib/commons/matches/attributes.js +23 -0
  290. data/node_modules/axe-core/lib/commons/matches/condition.js +19 -0
  291. data/node_modules/axe-core/lib/commons/matches/from-definition.js +47 -0
  292. data/node_modules/axe-core/lib/commons/matches/from-function.js +38 -0
  293. data/node_modules/axe-core/lib/commons/matches/from-primative.js +30 -0
  294. data/node_modules/axe-core/lib/commons/matches/index.js +37 -0
  295. data/node_modules/axe-core/lib/commons/matches/node-name.js +34 -0
  296. data/node_modules/axe-core/lib/commons/matches/properties.js +25 -0
  297. data/node_modules/axe-core/lib/commons/outro.stub +2 -0
  298. data/node_modules/axe-core/lib/commons/table/get-all-cells.js +28 -0
  299. data/node_modules/axe-core/lib/commons/table/get-cell-position.js +28 -0
  300. data/node_modules/axe-core/lib/commons/table/get-headers.js +29 -0
  301. data/node_modules/axe-core/lib/commons/table/get-scope.js +54 -0
  302. data/node_modules/axe-core/lib/commons/table/index.js +9 -0
  303. data/node_modules/axe-core/lib/commons/table/is-column-header.js +13 -0
  304. data/node_modules/axe-core/lib/commons/table/is-data-cell.js +22 -0
  305. data/node_modules/axe-core/lib/commons/table/is-data-table.js +190 -0
  306. data/node_modules/axe-core/lib/commons/table/is-header.js +22 -0
  307. data/node_modules/axe-core/lib/commons/table/is-row-header.js +13 -0
  308. data/node_modules/axe-core/lib/commons/table/to-grid.js +38 -0
  309. data/node_modules/axe-core/lib/commons/table/traverse.js +78 -0
  310. data/node_modules/axe-core/lib/commons/text/accessible-text-virtual.js +152 -0
  311. data/node_modules/axe-core/lib/commons/text/form-control-value.js +204 -0
  312. data/node_modules/axe-core/lib/commons/text/index.js +8 -0
  313. data/node_modules/axe-core/lib/commons/text/is-human-interpretable.js +51 -0
  314. data/node_modules/axe-core/lib/commons/text/is-valid-autocomplete.js +118 -0
  315. data/node_modules/axe-core/lib/commons/text/label-text.js +58 -0
  316. data/node_modules/axe-core/lib/commons/text/label-virtual.js +53 -0
  317. data/node_modules/axe-core/lib/commons/text/native-element-types.js +100 -0
  318. data/node_modules/axe-core/lib/commons/text/native-text-alternative.js +50 -0
  319. data/node_modules/axe-core/lib/commons/text/native-text-methods.js +122 -0
  320. data/node_modules/axe-core/lib/commons/text/sanitize.js +18 -0
  321. data/node_modules/axe-core/lib/commons/text/subtree-text.js +89 -0
  322. data/node_modules/axe-core/lib/commons/text/title-text.js +33 -0
  323. data/node_modules/axe-core/lib/commons/text/unicode.js +117 -0
  324. data/node_modules/axe-core/lib/commons/text/unsupported.js +5 -0
  325. data/node_modules/axe-core/lib/commons/text/visible-virtual.js +46 -0
  326. data/node_modules/axe-core/lib/commons/utils/index.js +10 -0
  327. data/node_modules/axe-core/lib/core/base/audit.js +684 -0
  328. data/node_modules/axe-core/lib/core/base/check-result.js +33 -0
  329. data/node_modules/axe-core/lib/core/base/check.js +123 -0
  330. data/node_modules/axe-core/lib/core/base/context.js +273 -0
  331. data/node_modules/axe-core/lib/core/base/rule-result.js +39 -0
  332. data/node_modules/axe-core/lib/core/base/rule.js +383 -0
  333. data/node_modules/axe-core/lib/core/constants.js +68 -0
  334. data/node_modules/axe-core/lib/core/imports/index.js +26 -0
  335. data/node_modules/axe-core/lib/core/index.js +45 -0
  336. data/node_modules/axe-core/lib/core/log.js +12 -0
  337. data/node_modules/axe-core/lib/core/public/cleanup-plugins.js +53 -0
  338. data/node_modules/axe-core/lib/core/public/configure.js +57 -0
  339. data/node_modules/axe-core/lib/core/public/get-rules.js +29 -0
  340. data/node_modules/axe-core/lib/core/public/load.js +66 -0
  341. data/node_modules/axe-core/lib/core/public/plugins.js +47 -0
  342. data/node_modules/axe-core/lib/core/public/reporter.js +24 -0
  343. data/node_modules/axe-core/lib/core/public/reset.js +12 -0
  344. data/node_modules/axe-core/lib/core/public/run-rules.js +94 -0
  345. data/node_modules/axe-core/lib/core/public/run.js +148 -0
  346. data/node_modules/axe-core/lib/core/reporters/helpers/failure-summary.js +35 -0
  347. data/node_modules/axe-core/lib/core/reporters/helpers/get-environment-data.js +39 -0
  348. data/node_modules/axe-core/lib/core/reporters/helpers/incomplete-fallback-msg.js +11 -0
  349. data/node_modules/axe-core/lib/core/reporters/helpers/index.js +3 -0
  350. data/node_modules/axe-core/lib/core/reporters/helpers/process-aggregate.js +102 -0
  351. data/node_modules/axe-core/lib/core/reporters/na.js +20 -0
  352. data/node_modules/axe-core/lib/core/reporters/no-passes.js +18 -0
  353. data/node_modules/axe-core/lib/core/reporters/raw.js +8 -0
  354. data/node_modules/axe-core/lib/core/reporters/v1.js +26 -0
  355. data/node_modules/axe-core/lib/core/reporters/v2.js +22 -0
  356. data/node_modules/axe-core/lib/core/utils/aggregate.js +19 -0
  357. data/node_modules/axe-core/lib/core/utils/aggregateChecks.js +85 -0
  358. data/node_modules/axe-core/lib/core/utils/aggregateNodeResults.js +61 -0
  359. data/node_modules/axe-core/lib/core/utils/aggregateResult.js +37 -0
  360. data/node_modules/axe-core/lib/core/utils/are-styles-set.js +24 -0
  361. data/node_modules/axe-core/lib/core/utils/check-helper.js +38 -0
  362. data/node_modules/axe-core/lib/core/utils/clone.js +27 -0
  363. data/node_modules/axe-core/lib/core/utils/collect-results-from-frames.js +127 -0
  364. data/node_modules/axe-core/lib/core/utils/contains.js +30 -0
  365. data/node_modules/axe-core/lib/core/utils/css-parser.js +5 -0
  366. data/node_modules/axe-core/lib/core/utils/dq-element.js +97 -0
  367. data/node_modules/axe-core/lib/core/utils/element-matches.js +39 -0
  368. data/node_modules/axe-core/lib/core/utils/escape-selector.js +79 -0
  369. data/node_modules/axe-core/lib/core/utils/extend-meta-data.js +17 -0
  370. data/node_modules/axe-core/lib/core/utils/finalize-result.js +11 -0
  371. data/node_modules/axe-core/lib/core/utils/find-by.js +14 -0
  372. data/node_modules/axe-core/lib/core/utils/flattened-tree.js +170 -0
  373. data/node_modules/axe-core/lib/core/utils/get-all-checks.js +12 -0
  374. data/node_modules/axe-core/lib/core/utils/get-base-lang.js +16 -0
  375. data/node_modules/axe-core/lib/core/utils/get-check-option.js +40 -0
  376. data/node_modules/axe-core/lib/core/utils/get-friendly-uri-end.js +144 -0
  377. data/node_modules/axe-core/lib/core/utils/get-root-node.js +17 -0
  378. data/node_modules/axe-core/lib/core/utils/get-selector.js +406 -0
  379. data/node_modules/axe-core/lib/core/utils/get-xpath.js +84 -0
  380. data/node_modules/axe-core/lib/core/utils/index.js +10 -0
  381. data/node_modules/axe-core/lib/core/utils/inject-style.js +38 -0
  382. data/node_modules/axe-core/lib/core/utils/is-hidden.js +40 -0
  383. data/node_modules/axe-core/lib/core/utils/is-html-element.js +135 -0
  384. data/node_modules/axe-core/lib/core/utils/is-shadow-root.js +40 -0
  385. data/node_modules/axe-core/lib/core/utils/is-xhtml.js +14 -0
  386. data/node_modules/axe-core/lib/core/utils/merge-results.js +116 -0
  387. data/node_modules/axe-core/lib/core/utils/node-sorter.js +21 -0
  388. data/node_modules/axe-core/lib/core/utils/performance-timer.js +121 -0
  389. data/node_modules/axe-core/lib/core/utils/pollyfills.js +299 -0
  390. data/node_modules/axe-core/lib/core/utils/preload-cssom.js +456 -0
  391. data/node_modules/axe-core/lib/core/utils/preload.js +109 -0
  392. data/node_modules/axe-core/lib/core/utils/publish-metadata.js +93 -0
  393. data/node_modules/axe-core/lib/core/utils/qsa.js +322 -0
  394. data/node_modules/axe-core/lib/core/utils/queue.js +138 -0
  395. data/node_modules/axe-core/lib/core/utils/respondable.js +243 -0
  396. data/node_modules/axe-core/lib/core/utils/rule-should-run.js +83 -0
  397. data/node_modules/axe-core/lib/core/utils/scroll-state.js +70 -0
  398. data/node_modules/axe-core/lib/core/utils/select.js +146 -0
  399. data/node_modules/axe-core/lib/core/utils/to-array.js +21 -0
  400. data/node_modules/axe-core/lib/core/utils/token-list.js +15 -0
  401. data/node_modules/axe-core/lib/core/utils/uuid.js +242 -0
  402. data/node_modules/axe-core/lib/core/utils/valid-input-type.js +35 -0
  403. data/node_modules/axe-core/lib/core/utils/valid-langs.js +8152 -0
  404. data/node_modules/axe-core/lib/intro.stub +15 -0
  405. data/node_modules/axe-core/lib/misc/any-failure-summary.json +6 -0
  406. data/node_modules/axe-core/lib/misc/incomplete-fallback.json +3 -0
  407. data/node_modules/axe-core/lib/misc/none-failure-summary.json +6 -0
  408. data/node_modules/axe-core/lib/outro.stub +2 -0
  409. data/node_modules/axe-core/lib/rules/accesskeys.json +13 -0
  410. data/node_modules/axe-core/lib/rules/area-alt.json +19 -0
  411. data/node_modules/axe-core/lib/rules/aria-allowed-attr-matches.js +11 -0
  412. data/node_modules/axe-core/lib/rules/aria-allowed-attr.json +12 -0
  413. data/node_modules/axe-core/lib/rules/aria-allowed-role-matches.js +7 -0
  414. data/node_modules/axe-core/lib/rules/aria-allowed-role.json +14 -0
  415. data/node_modules/axe-core/lib/rules/aria-dpub-role-fallback-matches.js +10 -0
  416. data/node_modules/axe-core/lib/rules/aria-dpub-role-fallback.json +13 -0
  417. data/node_modules/axe-core/lib/rules/aria-has-attr-matches.js +11 -0
  418. data/node_modules/axe-core/lib/rules/aria-hidden-body.json +13 -0
  419. data/node_modules/axe-core/lib/rules/aria-hidden-focus-matches.js +18 -0
  420. data/node_modules/axe-core/lib/rules/aria-hidden-focus.json +14 -0
  421. data/node_modules/axe-core/lib/rules/aria-required-attr.json +12 -0
  422. data/node_modules/axe-core/lib/rules/aria-required-children.json +12 -0
  423. data/node_modules/axe-core/lib/rules/aria-required-parent.json +12 -0
  424. data/node_modules/axe-core/lib/rules/aria-roles.json +12 -0
  425. data/node_modules/axe-core/lib/rules/aria-valid-attr-value.json +12 -0
  426. data/node_modules/axe-core/lib/rules/aria-valid-attr.json +12 -0
  427. data/node_modules/axe-core/lib/rules/audio-caption.json +20 -0
  428. data/node_modules/axe-core/lib/rules/autocomplete-matches.js +45 -0
  429. data/node_modules/axe-core/lib/rules/autocomplete-valid.json +12 -0
  430. data/node_modules/axe-core/lib/rules/blink.json +19 -0
  431. data/node_modules/axe-core/lib/rules/button-name.json +27 -0
  432. data/node_modules/axe-core/lib/rules/bypass-matches.js +1 -0
  433. data/node_modules/axe-core/lib/rules/bypass.json +20 -0
  434. data/node_modules/axe-core/lib/rules/checkboxgroup.json +12 -0
  435. data/node_modules/axe-core/lib/rules/color-contrast-matches.js +120 -0
  436. data/node_modules/axe-core/lib/rules/color-contrast.json +16 -0
  437. data/node_modules/axe-core/lib/rules/css-orientation-lock.json +13 -0
  438. data/node_modules/axe-core/lib/rules/data-table-large-matches.js +11 -0
  439. data/node_modules/axe-core/lib/rules/data-table-matches.js +1 -0
  440. data/node_modules/axe-core/lib/rules/definition-list.json +13 -0
  441. data/node_modules/axe-core/lib/rules/dlitem.json +13 -0
  442. data/node_modules/axe-core/lib/rules/document-title.json +13 -0
  443. data/node_modules/axe-core/lib/rules/duplicate-id-active-matches.js +8 -0
  444. data/node_modules/axe-core/lib/rules/duplicate-id-active.json +14 -0
  445. data/node_modules/axe-core/lib/rules/duplicate-id-aria-matches.js +1 -0
  446. data/node_modules/axe-core/lib/rules/duplicate-id-aria.json +14 -0
  447. data/node_modules/axe-core/lib/rules/duplicate-id-misc-matches.js +11 -0
  448. data/node_modules/axe-core/lib/rules/duplicate-id.json +14 -0
  449. data/node_modules/axe-core/lib/rules/empty-heading.json +13 -0
  450. data/node_modules/axe-core/lib/rules/focus-order-semantics.json +13 -0
  451. data/node_modules/axe-core/lib/rules/form-field-multiple-labels.json +13 -0
  452. data/node_modules/axe-core/lib/rules/frame-tested.json +12 -0
  453. data/node_modules/axe-core/lib/rules/frame-title-has-text.js +2 -0
  454. data/node_modules/axe-core/lib/rules/frame-title-unique.json +13 -0
  455. data/node_modules/axe-core/lib/rules/frame-title.json +25 -0
  456. data/node_modules/axe-core/lib/rules/heading-matches.js +15 -0
  457. data/node_modules/axe-core/lib/rules/heading-order.json +13 -0
  458. data/node_modules/axe-core/lib/rules/hidden-content.json +13 -0
  459. data/node_modules/axe-core/lib/rules/html-has-lang.json +12 -0
  460. data/node_modules/axe-core/lib/rules/html-lang-valid.json +12 -0
  461. data/node_modules/axe-core/lib/rules/html-xml-lang-mismatch.json +13 -0
  462. data/node_modules/axe-core/lib/rules/image-alt.json +25 -0
  463. data/node_modules/axe-core/lib/rules/img-redundant-alt.json +12 -0
  464. data/node_modules/axe-core/lib/rules/input-image-alt.json +18 -0
  465. data/node_modules/axe-core/lib/rules/inserted-into-focus-order-matches.js +1 -0
  466. data/node_modules/axe-core/lib/rules/label-content-name-mismatch-matches.js +42 -0
  467. data/node_modules/axe-core/lib/rules/label-content-name-mismatch.json +12 -0
  468. data/node_modules/axe-core/lib/rules/label-matches.js +11 -0
  469. data/node_modules/axe-core/lib/rules/label-title-only.json +13 -0
  470. data/node_modules/axe-core/lib/rules/label.json +26 -0
  471. data/node_modules/axe-core/lib/rules/landmark-banner-is-top-level.json +13 -0
  472. data/node_modules/axe-core/lib/rules/landmark-complementary-is-top-level.json +12 -0
  473. data/node_modules/axe-core/lib/rules/landmark-contentinfo-is-top-level.json +13 -0
  474. data/node_modules/axe-core/lib/rules/landmark-has-body-context.js +8 -0
  475. data/node_modules/axe-core/lib/rules/landmark-main-is-top-level.json +12 -0
  476. data/node_modules/axe-core/lib/rules/landmark-no-duplicate-banner.json +12 -0
  477. data/node_modules/axe-core/lib/rules/landmark-no-duplicate-contentinfo.json +12 -0
  478. data/node_modules/axe-core/lib/rules/landmark-one-main.json +12 -0
  479. data/node_modules/axe-core/lib/rules/layout-table-matches.js +8 -0
  480. data/node_modules/axe-core/lib/rules/layout-table.json +13 -0
  481. data/node_modules/axe-core/lib/rules/link-in-text-block-matches.js +14 -0
  482. data/node_modules/axe-core/lib/rules/link-in-text-block.json +14 -0
  483. data/node_modules/axe-core/lib/rules/link-name.json +26 -0
  484. data/node_modules/axe-core/lib/rules/list.json +13 -0
  485. data/node_modules/axe-core/lib/rules/listitem.json +13 -0
  486. data/node_modules/axe-core/lib/rules/marquee.json +13 -0
  487. data/node_modules/axe-core/lib/rules/meta-refresh.json +13 -0
  488. data/node_modules/axe-core/lib/rules/meta-viewport-large.json +13 -0
  489. data/node_modules/axe-core/lib/rules/meta-viewport.json +13 -0
  490. data/node_modules/axe-core/lib/rules/no-role-matches.js +1 -0
  491. data/node_modules/axe-core/lib/rules/not-html-matches.js +1 -0
  492. data/node_modules/axe-core/lib/rules/object-alt.json +25 -0
  493. data/node_modules/axe-core/lib/rules/p-as-heading-matches.js +17 -0
  494. data/node_modules/axe-core/lib/rules/p-as-heading.json +13 -0
  495. data/node_modules/axe-core/lib/rules/page-has-heading-one.json +12 -0
  496. data/node_modules/axe-core/lib/rules/radiogroup.json +12 -0
  497. data/node_modules/axe-core/lib/rules/region.json +13 -0
  498. data/node_modules/axe-core/lib/rules/role-not-button-matches.js +1 -0
  499. data/node_modules/axe-core/lib/rules/scope-attr-valid.json +12 -0
  500. data/node_modules/axe-core/lib/rules/server-side-image-map.json +18 -0
  501. data/node_modules/axe-core/lib/rules/skip-link-matches.js +1 -0
  502. data/node_modules/axe-core/lib/rules/skip-link.json +13 -0
  503. data/node_modules/axe-core/lib/rules/tabindex.json +12 -0
  504. data/node_modules/axe-core/lib/rules/table-duplicate-name.json +12 -0
  505. data/node_modules/axe-core/lib/rules/table-fake-caption.json +20 -0
  506. data/node_modules/axe-core/lib/rules/td-has-header.json +20 -0
  507. data/node_modules/axe-core/lib/rules/td-headers-attr.json +12 -0
  508. data/node_modules/axe-core/lib/rules/th-has-data-cells.json +13 -0
  509. data/node_modules/axe-core/lib/rules/valid-lang.json +13 -0
  510. data/node_modules/axe-core/lib/rules/video-caption.json +19 -0
  511. data/node_modules/axe-core/lib/rules/video-description.json +19 -0
  512. data/node_modules/axe-core/lib/rules/window-is-top.js +3 -0
  513. data/node_modules/axe-core/lib/rules/xml-lang-mismatch-matches.js +12 -0
  514. data/node_modules/axe-core/locales/de.json +627 -0
  515. data/node_modules/axe-core/locales/fr.json +667 -0
  516. data/node_modules/axe-core/locales/ja.json +728 -0
  517. data/node_modules/axe-core/locales/nl.json +36 -0
  518. data/node_modules/axe-core/package.json +215 -0
  519. data/node_modules/axe-core/sri-history.json +138 -0
  520. data/node_modules/axe-core/typings/axe-core/axe-core-tests.ts +180 -0
  521. data/node_modules/govuk-frontend/all.js +19 -14
  522. data/node_modules/govuk-frontend/components/error-summary/error-summary.js +1 -3
  523. data/node_modules/govuk-frontend/components/summary-list/macro-options.json +12 -6
  524. data/node_modules/govuk-frontend/components/summary-list/template.njk +1 -1
  525. data/node_modules/govuk-frontend/components/tabs/_tabs.scss +1 -1
  526. data/node_modules/govuk-frontend/helpers/_typography.scss +3 -2
  527. data/node_modules/govuk-frontend/objects/_main-wrapper.scss +10 -2
  528. data/node_modules/govuk-frontend/package.json +10 -10
  529. data/node_modules/govuk-frontend/settings/_typography-font.scss +12 -0
  530. metadata +513 -3
  531. data/app/assets/javascripts/component_guide/vendor/axe.min.js +0 -41
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Array#sort callback to sort nodes by DOM order
3
+ * @private
4
+ * @param {Node} nodeA
5
+ * @param {Node} nodeB
6
+ * @return {Integer} @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Sort
7
+ */
8
+ axe.utils.nodeSorter = function nodeSorter(nodeA, nodeB) {
9
+ /*eslint no-bitwise: 0 */
10
+ nodeA = nodeA.actualNode || nodeA;
11
+ nodeB = nodeB.actualNode || nodeB;
12
+ if (nodeA === nodeB) {
13
+ return 0;
14
+ }
15
+
16
+ if (nodeA.compareDocumentPosition(nodeB) & 4) {
17
+ return -1; // a before b
18
+ } else {
19
+ return 1; // b before a
20
+ }
21
+ };
@@ -0,0 +1,121 @@
1
+ /*global utils, axe */
2
+
3
+ /**
4
+ * Performance measuring utility shimming the User Timing API
5
+ *
6
+ * https://www.html5rocks.com/en/tutorials/webperformance/usertiming/
7
+ * http://caniuse.com/#search=User%20Timing
8
+ *
9
+ */
10
+ utils.performanceTimer = (function() {
11
+ 'use strict';
12
+
13
+ /**
14
+ * Get a time/date object using performance.now() if supported
15
+ * @return {DOMTimeStamp}
16
+ */
17
+ function now() {
18
+ if (window.performance && window.performance) {
19
+ return window.performance.now();
20
+ }
21
+ }
22
+ var originalTime = null;
23
+ var lastRecordedTime = now();
24
+
25
+ /**
26
+ * @typedef {utils.performanceTimer} Public API Methods
27
+ */
28
+ return {
29
+ /**
30
+ * @member {Function} start Kicks off performance timing for overall aXe audit
31
+ */
32
+ start: function() {
33
+ this.mark('mark_axe_start');
34
+ },
35
+ /**
36
+ * @member {Function} end Concludes performance timing, compares start/end marks
37
+ */
38
+ end: function() {
39
+ this.mark('mark_axe_end');
40
+ this.measure('axe', 'mark_axe_start', 'mark_axe_end');
41
+
42
+ this.logMeasures('axe');
43
+ },
44
+ /**
45
+ * @member {Function} auditStart Starts an audit for a page or frame
46
+ */
47
+ auditStart: function() {
48
+ this.mark('mark_audit_start');
49
+ },
50
+ /**
51
+ * @member {Function} auditEnd Ends an audit for a page or frame, logs measurement of start/end marks
52
+ */
53
+ auditEnd: function() {
54
+ this.mark('mark_audit_end');
55
+ this.measure('audit_start_to_end', 'mark_audit_start', 'mark_audit_end');
56
+ // log audit/rule measures
57
+ this.logMeasures();
58
+ },
59
+ /**
60
+ * @member {Function} mark Shims creating a new named time stamp, called a mark
61
+ * @param {String} markName String name to record how long it took to get there.
62
+ * A mark that already exists will be overwritten.
63
+ *
64
+ */
65
+ mark: function(markName) {
66
+ if (window.performance && window.performance.mark !== undefined) {
67
+ window.performance.mark(markName);
68
+ }
69
+ },
70
+ /**
71
+ * @member {Function} measure Shims creating a measure to compare two marks, which can be logged
72
+ * @param {String} measureName String name to log what is being compared.
73
+ * Measures that already exist will be overwritten with a new time stamp.
74
+ * @param {String} startMark String name of mark to start measuring
75
+ * @param {String} endMark String name of mark to end measuring
76
+ */
77
+ measure: function(measureName, startMark, endMark) {
78
+ if (window.performance && window.performance.measure !== undefined) {
79
+ window.performance.measure(measureName, startMark, endMark);
80
+ }
81
+ },
82
+ /**
83
+ * @member {Function} logMeasures Iterates through measures and logs any that exist
84
+ */
85
+ logMeasures: function(measureName) {
86
+ function log(req) {
87
+ axe.log('Measure ' + req.name + ' took ' + req.duration + 'ms');
88
+ }
89
+ if (
90
+ window.performance &&
91
+ window.performance.getEntriesByType !== undefined
92
+ ) {
93
+ var measures = window.performance.getEntriesByType('measure');
94
+ for (var i = 0; i < measures.length; ++i) {
95
+ var req = measures[i];
96
+ if (req.name === measureName) {
97
+ log(req);
98
+ return;
99
+ }
100
+ log(req);
101
+ }
102
+ }
103
+ },
104
+ /**
105
+ * @member {Function} timeElapsed Records time since last audit
106
+ * @return {DOMTimeStamp}
107
+ */
108
+ timeElapsed: function() {
109
+ return now() - lastRecordedTime;
110
+ },
111
+ /**
112
+ * @member {Function} reset Resets the time for a new audit
113
+ */
114
+ reset: function() {
115
+ if (!originalTime) {
116
+ originalTime = now();
117
+ }
118
+ lastRecordedTime = now();
119
+ }
120
+ };
121
+ })();
@@ -0,0 +1,299 @@
1
+ /* eslint-disable */
2
+ /*
3
+ These pollyfills came directly from the ES Specification it's self
4
+ Contained within:
5
+ - Object.assign
6
+ - Array.prototype.find
7
+ */
8
+ if (typeof Object.assign !== 'function') {
9
+ (function() {
10
+ Object.assign = function(target) {
11
+ 'use strict';
12
+ if (target === undefined || target === null) {
13
+ throw new TypeError('Cannot convert undefined or null to object');
14
+ }
15
+
16
+ var output = Object(target);
17
+ for (var index = 1; index < arguments.length; index++) {
18
+ var source = arguments[index];
19
+ if (source !== undefined && source !== null) {
20
+ for (var nextKey in source) {
21
+ if (source.hasOwnProperty(nextKey)) {
22
+ output[nextKey] = source[nextKey];
23
+ }
24
+ }
25
+ }
26
+ }
27
+ return output;
28
+ };
29
+ })();
30
+ }
31
+
32
+ if (!Array.prototype.find) {
33
+ Object.defineProperty(Array.prototype, 'find', {
34
+ value: function(predicate) {
35
+ if (this === null) {
36
+ throw new TypeError('Array.prototype.find called on null or undefined');
37
+ }
38
+ if (typeof predicate !== 'function') {
39
+ throw new TypeError('predicate must be a function');
40
+ }
41
+ var list = Object(this);
42
+ var length = list.length >>> 0;
43
+ var thisArg = arguments[1];
44
+ var value;
45
+
46
+ for (var i = 0; i < length; i++) {
47
+ value = list[i];
48
+ if (predicate.call(thisArg, value, i, list)) {
49
+ return value;
50
+ }
51
+ }
52
+ return undefined;
53
+ }
54
+ });
55
+ }
56
+
57
+ axe.utils.pollyfillElementsFromPoint = function() {
58
+ if (document.elementsFromPoint) return document.elementsFromPoint;
59
+ if (document.msElementsFromPoint) return document.msElementsFromPoint;
60
+
61
+ var usePointer = (function() {
62
+ var element = document.createElement('x');
63
+ element.style.cssText = 'pointer-events:auto';
64
+ return element.style.pointerEvents === 'auto';
65
+ })();
66
+
67
+ var cssProp = usePointer ? 'pointer-events' : 'visibility';
68
+ var cssDisableVal = usePointer ? 'none' : 'hidden';
69
+
70
+ var style = document.createElement('style');
71
+ style.innerHTML = usePointer
72
+ ? '* { pointer-events: all }'
73
+ : '* { visibility: visible }';
74
+
75
+ return function(x, y) {
76
+ var current, i, d;
77
+ var elements = [];
78
+ var previousPointerEvents = [];
79
+
80
+ // startup
81
+ document.head.appendChild(style);
82
+
83
+ while (
84
+ (current = document.elementFromPoint(x, y)) &&
85
+ elements.indexOf(current) === -1
86
+ ) {
87
+ // push the element and its current style
88
+ elements.push(current);
89
+
90
+ previousPointerEvents.push({
91
+ value: current.style.getPropertyValue(cssProp),
92
+ priority: current.style.getPropertyPriority(cssProp)
93
+ });
94
+
95
+ // add "pointer-events: none", to get to the underlying element
96
+ current.style.setProperty(cssProp, cssDisableVal, 'important');
97
+ }
98
+
99
+ // Due to negative index, documentElement could actually not be the last,
100
+ // so we'll simply move it to the end
101
+ if (elements.indexOf(document.documentElement) < elements.length - 1) {
102
+ elements.splice(elements.indexOf(document.documentElement), 1);
103
+ elements.push(document.documentElement);
104
+ }
105
+
106
+ // restore the previous pointer-events values
107
+ for (
108
+ i = previousPointerEvents.length;
109
+ !!(d = previousPointerEvents[--i]);
110
+
111
+ ) {
112
+ elements[i].style.setProperty(
113
+ cssProp,
114
+ d.value ? d.value : '',
115
+ d.priority
116
+ );
117
+ }
118
+
119
+ // teardown;
120
+ document.head.removeChild(style);
121
+
122
+ return elements;
123
+ };
124
+ };
125
+
126
+ if (typeof window.addEventListener === 'function') {
127
+ document.elementsFromPoint = axe.utils.pollyfillElementsFromPoint();
128
+ }
129
+
130
+ if (!Array.prototype.includes) {
131
+ Object.defineProperty(Array.prototype, 'includes', {
132
+ value: function(searchElement) {
133
+ 'use strict';
134
+ var O = Object(this);
135
+ var len = parseInt(O.length, 10) || 0;
136
+ if (len === 0) {
137
+ return false;
138
+ }
139
+ var n = parseInt(arguments[1], 10) || 0;
140
+ var k;
141
+ if (n >= 0) {
142
+ k = n;
143
+ } else {
144
+ k = len + n;
145
+ if (k < 0) {
146
+ k = 0;
147
+ }
148
+ }
149
+ var currentElement;
150
+ while (k < len) {
151
+ currentElement = O[k];
152
+ if (
153
+ searchElement === currentElement ||
154
+ (searchElement !== searchElement && currentElement !== currentElement)
155
+ ) {
156
+ // NaN !== NaN
157
+ return true;
158
+ }
159
+ k++;
160
+ }
161
+ return false;
162
+ }
163
+ });
164
+ }
165
+
166
+ // Production steps of ECMA-262, Edition 5, 15.4.4.17
167
+ // Reference: http://es5.github.io/#x15.4.4.17
168
+ if (!Array.prototype.some) {
169
+ Object.defineProperty(Array.prototype, 'some', {
170
+ value: function(fun) {
171
+ 'use strict';
172
+
173
+ if (this == null) {
174
+ throw new TypeError('Array.prototype.some called on null or undefined');
175
+ }
176
+
177
+ if (typeof fun !== 'function') {
178
+ throw new TypeError();
179
+ }
180
+
181
+ var t = Object(this);
182
+ var len = t.length >>> 0;
183
+
184
+ var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
185
+ for (var i = 0; i < len; i++) {
186
+ if (i in t && fun.call(thisArg, t[i], i, t)) {
187
+ return true;
188
+ }
189
+ }
190
+
191
+ return false;
192
+ }
193
+ });
194
+ }
195
+
196
+ if (!Array.from) {
197
+ Object.defineProperty(Array, 'from', {
198
+ value: (function() {
199
+ var toStr = Object.prototype.toString;
200
+ var isCallable = function(fn) {
201
+ return (
202
+ typeof fn === 'function' || toStr.call(fn) === '[object Function]'
203
+ );
204
+ };
205
+ var toInteger = function(value) {
206
+ var number = Number(value);
207
+ if (isNaN(number)) {
208
+ return 0;
209
+ }
210
+ if (number === 0 || !isFinite(number)) {
211
+ return number;
212
+ }
213
+ return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
214
+ };
215
+ var maxSafeInteger = Math.pow(2, 53) - 1;
216
+ var toLength = function(value) {
217
+ var len = toInteger(value);
218
+ return Math.min(Math.max(len, 0), maxSafeInteger);
219
+ };
220
+
221
+ // The length property of the from method is 1.
222
+ return function from(arrayLike /*, mapFn, thisArg */) {
223
+ // 1. Let C be the this value.
224
+ var C = this;
225
+
226
+ // 2. Let items be ToObject(arrayLike).
227
+ var items = Object(arrayLike);
228
+
229
+ // 3. ReturnIfAbrupt(items).
230
+ if (arrayLike == null) {
231
+ throw new TypeError(
232
+ 'Array.from requires an array-like object - not null or undefined'
233
+ );
234
+ }
235
+
236
+ // 4. If mapfn is undefined, then let mapping be false.
237
+ var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
238
+ var T;
239
+ if (typeof mapFn !== 'undefined') {
240
+ // 5. else
241
+ // 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
242
+ if (!isCallable(mapFn)) {
243
+ throw new TypeError(
244
+ 'Array.from: when provided, the second argument must be a function'
245
+ );
246
+ }
247
+
248
+ // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
249
+ if (arguments.length > 2) {
250
+ T = arguments[2];
251
+ }
252
+ }
253
+
254
+ // 10. Let lenValue be Get(items, "length").
255
+ // 11. Let len be ToLength(lenValue).
256
+ var len = toLength(items.length);
257
+
258
+ // 13. If IsConstructor(C) is true, then
259
+ // 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len.
260
+ // 14. a. Else, Let A be ArrayCreate(len).
261
+ var A = isCallable(C) ? Object(new C(len)) : new Array(len);
262
+
263
+ // 16. Let k be 0.
264
+ var k = 0;
265
+ // 17. Repeat, while k < len… (also steps a - h)
266
+ var kValue;
267
+ while (k < len) {
268
+ kValue = items[k];
269
+ if (mapFn) {
270
+ A[k] =
271
+ typeof T === 'undefined'
272
+ ? mapFn(kValue, k)
273
+ : mapFn.call(T, kValue, k);
274
+ } else {
275
+ A[k] = kValue;
276
+ }
277
+ k += 1;
278
+ }
279
+ // 18. Let putStatus be Put(A, "length", len, true).
280
+ A.length = len;
281
+ // 20. Return A.
282
+ return A;
283
+ };
284
+ })()
285
+ });
286
+ }
287
+
288
+ if (!String.prototype.includes) {
289
+ String.prototype.includes = function(search, start) {
290
+ if (typeof start !== 'number') {
291
+ start = 0;
292
+ }
293
+ if (start + search.length > this.length) {
294
+ return false;
295
+ } else {
296
+ return this.indexOf(search, start) !== -1;
297
+ }
298
+ };
299
+ }
@@ -0,0 +1,456 @@
1
+ /**
2
+ * NOTE:
3
+ * this `eslint` rule is disabled because of calling `getStyleSheetFactory` before it is defined (further below).
4
+ */
5
+ /* eslint no-use-before-define: 0 */
6
+
7
+
8
+ /**
9
+ * Given a rootNode - construct CSSOM
10
+ * -> get all source nodes (document & document fragments) within given root node
11
+ * -> recursively call `loadCssom` to resolve styles
12
+ *
13
+ * @method preloadCssom
14
+ * @memberof `axe.utils`
15
+ *
16
+ * @param {Object} object argument which is a composite object, with attributes timeout, treeRoot(optional), resolve & reject
17
+ * @property {Number} timeout timeout for any network calls made
18
+ * @property {Object} treeRoot the DOM tree to be inspected
19
+ * @returns {Object} `axe.utils.queue` with CSSOM assets
20
+ */
21
+ axe.utils.preloadCssom = function preloadCssom({
22
+ timeout,
23
+ treeRoot = axe._tree[0]
24
+ }) {
25
+ /**
26
+ * get all `document` and `documentFragment` with in given `tree`
27
+ */
28
+ const rootNodes = getAllRootNodesInTree(treeRoot);
29
+
30
+ const q = axe.utils.queue();
31
+
32
+ if (!rootNodes.length) {
33
+ return q;
34
+ }
35
+
36
+ const dynamicDoc = document.implementation.createHTMLDocument();
37
+ const convertDataToStylesheet = getStyleSheetFactory(dynamicDoc);
38
+
39
+ q.defer((resolve, reject) => {
40
+ getCssomForAllRootNodes(rootNodes, convertDataToStylesheet, timeout)
41
+ .then(assets => {
42
+ const cssom = processCssomAssets(assets);
43
+ resolve(cssom);
44
+ })
45
+ .catch(reject);
46
+ });
47
+
48
+ return q;
49
+ };
50
+
51
+ /**
52
+ * Returns am array of source nodes containing `document` and `documentFragment` in a given `tree`.
53
+ *
54
+ * @param {Object} treeRoot tree
55
+ * @returns {Array<Object>} array of objects, which each object containing a root and an optional `shadowId`
56
+ */
57
+ function getAllRootNodesInTree(tree) {
58
+ let ids = [];
59
+
60
+ const rootNodes = axe.utils
61
+ .querySelectorAllFilter(tree, '*', node => {
62
+ if (ids.includes(node.shadowId)) {
63
+ return false;
64
+ }
65
+ ids.push(node.shadowId);
66
+ return true;
67
+ })
68
+ .map(node => {
69
+ return {
70
+ shadowId: node.shadowId,
71
+ rootNode: axe.utils.getRootNode(node.actualNode)
72
+ };
73
+ });
74
+
75
+ return axe.utils.uniqueArray(rootNodes, []);
76
+ }
77
+
78
+ /**
79
+ * Convert text to CSSStyleSheet
80
+ * Is a factory (closure) function, initialized with `document.implementation.createHTMLDocument()` which surfaces DOM API for creating `style` elements.
81
+ *
82
+ * @param {Object} param `document.implementation.createHTMLDocument()
83
+ * @param {Object} arg an object with properties to construct stylesheet
84
+ * @property {String} arg.data text content of the stylesheet
85
+ * @property {Boolean} arg.isExternal flag to notify if the resource was fetched from the network
86
+ * @property {String} arg.shadowId (Optional) shadowId if shadowDOM
87
+ * @property {Object} arg.root implementation document to create style elements
88
+ * @property {String} arg.priority a number indicating the loaded priority of CSS, to denote specificity of styles contained in the sheet.
89
+ */
90
+ const getStyleSheetFactory = dynamicDoc => ({
91
+ data,
92
+ isExternal,
93
+ shadowId,
94
+ root,
95
+ priority,
96
+ isLink = false
97
+ }) => {
98
+ const style = dynamicDoc.createElement('style');
99
+ if (isLink) {
100
+ // as creating a stylesheet as link will need to be awaited
101
+ // till `onload`, it is wise to convert link href to @import statement
102
+ const text = dynamicDoc.createTextNode(`@import "${data.href}"`);
103
+ style.appendChild(text);
104
+ } else {
105
+ style.appendChild(dynamicDoc.createTextNode(data));
106
+ }
107
+ dynamicDoc.head.appendChild(style);
108
+ return {
109
+ sheet: style.sheet,
110
+ isExternal,
111
+ shadowId,
112
+ root,
113
+ priority
114
+ };
115
+ };
116
+
117
+ /**
118
+ * Deferred function for CSSOM queue processing on all root nodes
119
+ *
120
+ * @param {Array<Object>} rootNodes array of root nodes, where node is an enhanced `document` or `documentFragment` object returned from `getAllRootNodesInTree`
121
+ * @param {Function} convertDataToStylesheet fn to convert given data to Stylesheet object
122
+ * @returns {Object} `axe.utils.queue`
123
+ */
124
+ function getCssomForAllRootNodes(rootNodes, convertDataToStylesheet, timeout) {
125
+ const q = axe.utils.queue();
126
+
127
+ rootNodes.forEach(({ rootNode, shadowId }, index) =>
128
+ q.defer((resolve, reject) =>
129
+ loadCssom({
130
+ rootNode,
131
+ shadowId,
132
+ timeout,
133
+ convertDataToStylesheet,
134
+ rootIndex: index + 1
135
+ })
136
+ .then(resolve)
137
+ .catch(reject)
138
+ )
139
+ );
140
+
141
+ return q;
142
+ }
143
+
144
+ /**
145
+ * Process results from `loadCssom` queues of all root nodes
146
+ * NOTE:
147
+ * using `axe.utils.queue` from various `loadCssom` paths, returns a nested array of arrays at various depths,
148
+ * hence the need to flatten arrays
149
+ *
150
+ * @param {Array<Object>} assets CSSOM assets for each root
151
+ * @returns {Object} CSSOM object
152
+ */
153
+ function processCssomAssets(nestedAssets) {
154
+ const result = [];
155
+
156
+ nestedAssets.forEach(item => {
157
+ if (Array.isArray(item)) {
158
+ result.push(...processCssomAssets(item));
159
+ } else {
160
+ result.push(item);
161
+ }
162
+ });
163
+
164
+ return result;
165
+ }
166
+
167
+ /**
168
+ * Returns `axe.utils.queue` of CSSStyleSheet(s) for a given root node
169
+ *
170
+ * @param {Object} options configuration options
171
+ * @property {Object} options.rootNode document or document fragment
172
+ * @property {Number} options.rootIndex a number representing the index of the document or document fragment, used for priority computation
173
+ * @property {String} options.shadowId an id if undefined denotes that given root is a document fragment/ shadowDOM
174
+ * @property {Number} options.timeout abort duration for network request
175
+ * @property {Function} options.convertDataToStylesheet a utility function to generate a style sheet from given data (text)
176
+ * @return {Object} queue
177
+ */
178
+ function loadCssom(options) {
179
+ const { rootIndex } = options;
180
+
181
+ const q = axe.utils.queue();
182
+
183
+ const sheets = getStylesheetsOfRootNode(options);
184
+ if (!sheets) {
185
+ return q;
186
+ }
187
+
188
+ sheets.forEach((sheet, sheetIndex) => {
189
+ const priority = [rootIndex, sheetIndex];
190
+ try {
191
+ const deferredQ = parseNonCrossOriginStylesheet(sheet, options, priority);
192
+ q.defer(deferredQ);
193
+ } catch (e) {
194
+ // cross-origin stylesheet -> make an XHR and q the response
195
+ const deferredQ = parseCrossOriginStylesheet(
196
+ sheet.href,
197
+ options,
198
+ priority
199
+ );
200
+ q.defer(deferredQ);
201
+ }
202
+ });
203
+
204
+ return q;
205
+ }
206
+
207
+ /**
208
+ * Parse non cross-origin stylesheets
209
+ *
210
+ * @param {Object} sheet CSSStylesheet object
211
+ * @param {Object} options `loadCssom` options
212
+ * @param {Array<Number>} priority sheet priority
213
+ */
214
+ function parseNonCrossOriginStylesheet(sheet, options, priority) {
215
+ const q = axe.utils.queue();
216
+
217
+ /**
218
+ * `sheet.cssRules` throws an error on `cross-origin` stylesheets
219
+ */
220
+ const cssRules = sheet.cssRules;
221
+
222
+ const rules = Array.from(cssRules);
223
+ if (!rules) {
224
+ return q;
225
+ }
226
+
227
+ /**
228
+ * reference -> https://developer.mozilla.org/en-US/docs/Web/API/CSSRule#Type_constants
229
+ */
230
+ const cssImportRules = rules.filter(r => r.type === 3); // type === 3 -> CSSRule.IMPORT_RULE
231
+
232
+ /**
233
+ * when no `@import` rules in given sheet
234
+ * -> resolve the current `sheet` & exit
235
+ */
236
+ if (!cssImportRules.length) {
237
+ q.defer(resolve =>
238
+ resolve({
239
+ isExternal: false,
240
+ priority,
241
+ root: options.rootNode,
242
+ shadowId: options.shadowId,
243
+ sheet
244
+ })
245
+ );
246
+
247
+ // exit
248
+ return q;
249
+ }
250
+
251
+ /**
252
+ * iterate `@import` rules and fetch styles
253
+ */
254
+ cssImportRules.forEach((importRule, cssRuleIndex) =>
255
+ q.defer((resolve, reject) => {
256
+ const importUrl = importRule.href;
257
+ const newPriority = [...priority, cssRuleIndex];
258
+ const axiosOptions = {
259
+ method: 'get',
260
+ url: importUrl,
261
+ timeout: options.timeout
262
+ };
263
+ axe.imports
264
+ .axios(axiosOptions)
265
+ .then(({ data }) =>
266
+ resolve(
267
+ options.convertDataToStylesheet({
268
+ data,
269
+ isExternal: true,
270
+ priority: newPriority,
271
+ root: options.rootNode,
272
+ shadowId: options.shadowId
273
+ })
274
+ )
275
+ )
276
+ .catch(reject);
277
+ })
278
+ );
279
+
280
+ const nonImportCSSRules = rules.filter(r => r.type !== 3);
281
+
282
+ // no further rules to process in this sheet
283
+ if (!nonImportCSSRules.length) {
284
+ return q;
285
+ }
286
+
287
+ // convert all `nonImportCSSRules` style rules into `text` and defer into queue
288
+ q.defer(resolve =>
289
+ resolve(
290
+ options.convertDataToStylesheet({
291
+ data: nonImportCSSRules.map(rule => rule.cssText).join(),
292
+ isExternal: false,
293
+ priority,
294
+ root: options.rootNode,
295
+ shadowId: options.shadowId
296
+ })
297
+ )
298
+ );
299
+
300
+ return q;
301
+ }
302
+
303
+ /**
304
+ * Parse cross-origin stylesheets
305
+ *
306
+ * @param {String} url url from which to fetch stylesheet
307
+ * @param {Object} options `loadCssom` options
308
+ * @param {Array<Number>} priority sheet priority
309
+ */
310
+ function parseCrossOriginStylesheet(url, options, priority) {
311
+ const q = axe.utils.queue();
312
+
313
+ if (!url) {
314
+ return q;
315
+ }
316
+
317
+ const axiosOptions = {
318
+ method: 'get',
319
+ url,
320
+ timeout: options.timeout
321
+ };
322
+
323
+ q.defer((resolve, reject) => {
324
+ axe.imports
325
+ .axios(axiosOptions)
326
+ .then(({ data }) =>
327
+ resolve(
328
+ options.convertDataToStylesheet({
329
+ data,
330
+ isExternal: true,
331
+ priority,
332
+ root: options.rootNode,
333
+ shadowId: options.shadowId
334
+ })
335
+ )
336
+ )
337
+ .catch(reject);
338
+ });
339
+
340
+ return q;
341
+ }
342
+
343
+ /**
344
+ * Get stylesheet(s) for root
345
+ *
346
+ * @param {Object} options configuration options of `loadCssom`
347
+ * @returns an array of stylesheets
348
+ */
349
+ function getStylesheetsOfRootNode(options) {
350
+ const { rootNode, shadowId } = options;
351
+ let sheets;
352
+
353
+ // nodeType === 11 -> DOCUMENT_FRAGMENT
354
+ if (rootNode.nodeType === 11 && shadowId) {
355
+ sheets = getStylesheetsFromDocumentFragment(options);
356
+ } else {
357
+ sheets = getStylesheetsFromDocument(rootNode);
358
+ }
359
+
360
+ return filterStylesheetsWithSameHref(sheets);
361
+ }
362
+
363
+ /**
364
+ * Get stylesheets from `documentFragment`
365
+ *
366
+ * @param {Object} options configuration options of `loadCssom`
367
+ * @returns {Array<Object>}
368
+ */
369
+ function getStylesheetsFromDocumentFragment(options) {
370
+ const { rootNode, convertDataToStylesheet } = options;
371
+ return (
372
+ Array.from(rootNode.children)
373
+ .filter(filerStyleAndLinkAttributesInDocumentFragment)
374
+ // Reducer to convert `<style></style>` and `<link>` references to `CSSStyleSheet` object
375
+ .reduce((out, node) => {
376
+ const nodeName = node.nodeName.toUpperCase();
377
+ const data = nodeName === 'STYLE' ? node.textContent : node;
378
+ const isLink = nodeName === 'LINK';
379
+ const stylesheet = convertDataToStylesheet({
380
+ data,
381
+ isLink,
382
+ root: rootNode
383
+ });
384
+ out.push(stylesheet.sheet);
385
+ return out;
386
+ }, [])
387
+ );
388
+ }
389
+
390
+ /**
391
+ * Get stylesheets from `document`
392
+ * -> filter out stylesheet that are `media=print`
393
+ *
394
+ * @param {Object} rootNode `document`
395
+ * @returns {Array<Object>}
396
+ */
397
+ function getStylesheetsFromDocument(rootNode) {
398
+ return Array.from(rootNode.styleSheets).filter(sheet =>
399
+ filterMediaIsPrint(sheet.media.mediaText)
400
+ );
401
+ }
402
+
403
+ /**
404
+ * Get all `<style></style>` and `<link>` attributes
405
+ * -> limit to only `style` or `link` attributes with `rel=stylesheet` and `media != print`
406
+ *
407
+ * @param {Object} node HTMLElement
408
+ * @returns {Boolean}
409
+ */
410
+ function filerStyleAndLinkAttributesInDocumentFragment(node) {
411
+ const nodeName = node.nodeName.toUpperCase();
412
+ const linkHref = node.getAttribute('href');
413
+ const linkRel = node.getAttribute('rel');
414
+ const isLink =
415
+ nodeName === 'LINK' &&
416
+ linkHref &&
417
+ linkRel &&
418
+ node.rel.toUpperCase().includes('STYLESHEET');
419
+ const isStyle = nodeName === 'STYLE';
420
+ return isStyle || (isLink && filterMediaIsPrint(node.media));
421
+ }
422
+
423
+ /**
424
+ * Exclude `link[rel='stylesheet]` attributes where `media=print`
425
+ *
426
+ * @param {String} media media value eg: 'print'
427
+ * @returns {Boolean}
428
+ */
429
+ function filterMediaIsPrint(media) {
430
+ if (!media) {
431
+ return true;
432
+ }
433
+ return !media.toUpperCase().includes('PRINT');
434
+ }
435
+
436
+ /**
437
+ * Exclude any duplicate `stylesheets`, that share the same `href`
438
+ *
439
+ * @param {Array<Object>} sheets stylesheets
440
+ * @returns {Array<Object>}
441
+ */
442
+ function filterStylesheetsWithSameHref(sheets) {
443
+ let hrefs = [];
444
+ return sheets.filter(sheet => {
445
+ if (!sheet.href) {
446
+ // include sheets without `href`
447
+ return true;
448
+ }
449
+ // if `href` is present, ensure they are not duplicates
450
+ if (hrefs.includes(sheet.href)) {
451
+ return false;
452
+ }
453
+ hrefs.push(sheet.href);
454
+ return true;
455
+ });
456
+ }