govuk_publishing_components 18.1.0 → 18.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/CHANGELOG.md +741 -0
- data/node_modules/axe-core/CONTRIBUTING.md +187 -0
- data/node_modules/axe-core/LICENSE +362 -0
- data/node_modules/axe-core/README.md +147 -0
- data/node_modules/axe-core/axe.d.ts +216 -0
- data/node_modules/axe-core/axe.js +15298 -0
- data/node_modules/axe-core/axe.min.js +12 -0
- data/node_modules/axe-core/bower.json +40 -0
- data/node_modules/axe-core/doc/API.md +798 -0
- data/node_modules/axe-core/doc/accessibility-supported.md +33 -0
- data/node_modules/axe-core/doc/act-rules-format.md +37 -0
- data/node_modules/axe-core/doc/aria-supported.md +23 -0
- data/node_modules/axe-core/doc/axelogo2018.png +0 -0
- data/node_modules/axe-core/doc/code-submission-guidelines.md +178 -0
- data/node_modules/axe-core/doc/developer-guide.md +500 -0
- data/node_modules/axe-core/doc/examples/chrome-debugging-protocol/README.md +13 -0
- data/node_modules/axe-core/doc/examples/chrome-debugging-protocol/axe-cdp.js +81 -0
- data/node_modules/axe-core/doc/examples/chrome-debugging-protocol/package.json +8 -0
- data/node_modules/axe-core/doc/examples/html-handlebars.md +164 -0
- data/node_modules/axe-core/doc/examples/jasmine/README.md +37 -0
- data/node_modules/axe-core/doc/examples/jasmine/package.json +20 -0
- data/node_modules/axe-core/doc/examples/jasmine/spec/a11y.js +36 -0
- data/node_modules/axe-core/doc/examples/jest_react/README.md +41 -0
- data/node_modules/axe-core/doc/examples/jest_react/link.js +7 -0
- data/node_modules/axe-core/doc/examples/jest_react/link.test.js +24 -0
- data/node_modules/axe-core/doc/examples/jest_react/package.json +28 -0
- data/node_modules/axe-core/doc/examples/jest_react/test-helpers.js +21 -0
- data/node_modules/axe-core/doc/examples/mocha/README.md +37 -0
- data/node_modules/axe-core/doc/examples/mocha/package.json +21 -0
- data/node_modules/axe-core/doc/examples/phantomjs/README.md +17 -0
- data/node_modules/axe-core/doc/examples/phantomjs/axe-phantom.js +51 -0
- data/node_modules/axe-core/doc/examples/phantomjs/package.json +19 -0
- data/node_modules/axe-core/doc/examples/puppeteer/README.md +12 -0
- data/node_modules/axe-core/doc/examples/puppeteer/axe-puppeteer.js +60 -0
- data/node_modules/axe-core/doc/examples/puppeteer/package.json +10 -0
- data/node_modules/axe-core/doc/examples/qunit/README.md +37 -0
- data/node_modules/axe-core/doc/examples/qunit/package.json +21 -0
- data/node_modules/axe-core/doc/plugins.md +123 -0
- data/node_modules/axe-core/doc/projects.md +44 -0
- data/node_modules/axe-core/doc/rule-descriptions.md +79 -0
- data/node_modules/axe-core/doc/rule-development.md +95 -0
- data/node_modules/axe-core/doc/rule-proposal.md +106 -0
- data/node_modules/axe-core/lib/checks/aria/abstractrole.js +1 -0
- data/node_modules/axe-core/lib/checks/aria/abstractrole.json +11 -0
- data/node_modules/axe-core/lib/checks/aria/allowed-attr.js +39 -0
- data/node_modules/axe-core/lib/checks/aria/allowed-attr.json +11 -0
- data/node_modules/axe-core/lib/checks/aria/aria-allowed-role.js +28 -0
- data/node_modules/axe-core/lib/checks/aria/aria-allowed-role.json +16 -0
- data/node_modules/axe-core/lib/checks/aria/aria-hidden-body.js +1 -0
- data/node_modules/axe-core/lib/checks/aria/aria-hidden-body.json +11 -0
- data/node_modules/axe-core/lib/checks/aria/errormessage.js +33 -0
- data/node_modules/axe-core/lib/checks/aria/errormessage.json +11 -0
- data/node_modules/axe-core/lib/checks/aria/has-widget-role.js +6 -0
- data/node_modules/axe-core/lib/checks/aria/has-widget-role.json +12 -0
- data/node_modules/axe-core/lib/checks/aria/implicit-role-fallback.js +6 -0
- data/node_modules/axe-core/lib/checks/aria/implicit-role-fallback.json +11 -0
- data/node_modules/axe-core/lib/checks/aria/invalidrole.js +3 -0
- data/node_modules/axe-core/lib/checks/aria/invalidrole.json +11 -0
- data/node_modules/axe-core/lib/checks/aria/required-attr.js +28 -0
- data/node_modules/axe-core/lib/checks/aria/required-attr.json +11 -0
- data/node_modules/axe-core/lib/checks/aria/required-children.js +117 -0
- data/node_modules/axe-core/lib/checks/aria/required-children.json +15 -0
- data/node_modules/axe-core/lib/checks/aria/required-parent.js +87 -0
- data/node_modules/axe-core/lib/checks/aria/required-parent.json +11 -0
- data/node_modules/axe-core/lib/checks/aria/unsupportedattr.js +39 -0
- data/node_modules/axe-core/lib/checks/aria/unsupportedattr.json +11 -0
- data/node_modules/axe-core/lib/checks/aria/unsupportedrole.js +1 -0
- data/node_modules/axe-core/lib/checks/aria/unsupportedrole.json +11 -0
- data/node_modules/axe-core/lib/checks/aria/valid-attr-value.js +32 -0
- data/node_modules/axe-core/lib/checks/aria/valid-attr-value.json +12 -0
- data/node_modules/axe-core/lib/checks/aria/valid-attr.js +25 -0
- data/node_modules/axe-core/lib/checks/aria/valid-attr.json +12 -0
- data/node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js +62 -0
- data/node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.json +12 -0
- data/node_modules/axe-core/lib/checks/color/color-contrast.js +70 -0
- data/node_modules/axe-core/lib/checks/color/color-contrast.json +24 -0
- data/node_modules/axe-core/lib/checks/color/link-in-text-block.js +85 -0
- data/node_modules/axe-core/lib/checks/color/link-in-text-block.json +19 -0
- data/node_modules/axe-core/lib/checks/forms/autocomplete-appropriate.js +67 -0
- data/node_modules/axe-core/lib/checks/forms/autocomplete-appropriate.json +11 -0
- data/node_modules/axe-core/lib/checks/forms/autocomplete-valid.js +2 -0
- data/node_modules/axe-core/lib/checks/forms/autocomplete-valid.json +11 -0
- data/node_modules/axe-core/lib/checks/forms/fieldset-after.js +25 -0
- data/node_modules/axe-core/lib/checks/forms/fieldset.js +109 -0
- data/node_modules/axe-core/lib/checks/forms/fieldset.json +12 -0
- data/node_modules/axe-core/lib/checks/forms/group-labelledby-after.js +16 -0
- data/node_modules/axe-core/lib/checks/forms/group-labelledby.js +66 -0
- data/node_modules/axe-core/lib/checks/forms/group-labelledby.json +12 -0
- data/node_modules/axe-core/lib/checks/keyboard/accesskeys-after.js +19 -0
- data/node_modules/axe-core/lib/checks/keyboard/accesskeys.js +5 -0
- data/node_modules/axe-core/lib/checks/keyboard/accesskeys.json +12 -0
- data/node_modules/axe-core/lib/checks/keyboard/focusable-disabled.js +25 -0
- data/node_modules/axe-core/lib/checks/keyboard/focusable-disabled.json +11 -0
- data/node_modules/axe-core/lib/checks/keyboard/focusable-no-name.js +6 -0
- data/node_modules/axe-core/lib/checks/keyboard/focusable-no-name.json +11 -0
- data/node_modules/axe-core/lib/checks/keyboard/focusable-not-tabbable.js +25 -0
- data/node_modules/axe-core/lib/checks/keyboard/focusable-not-tabbable.json +11 -0
- data/node_modules/axe-core/lib/checks/keyboard/landmark-is-top-level.js +18 -0
- data/node_modules/axe-core/lib/checks/keyboard/landmark-is-top-level.json +11 -0
- data/node_modules/axe-core/lib/checks/keyboard/page-has-elm-after.js +11 -0
- data/node_modules/axe-core/lib/checks/keyboard/page-has-elm.js +9 -0
- data/node_modules/axe-core/lib/checks/keyboard/page-has-heading-one.json +15 -0
- data/node_modules/axe-core/lib/checks/keyboard/page-has-main.json +15 -0
- data/node_modules/axe-core/lib/checks/keyboard/page-no-duplicate-banner.json +15 -0
- data/node_modules/axe-core/lib/checks/keyboard/page-no-duplicate-contentinfo.json +15 -0
- data/node_modules/axe-core/lib/checks/keyboard/page-no-duplicate-main.json +14 -0
- data/node_modules/axe-core/lib/checks/keyboard/page-no-duplicate.js +22 -0
- data/node_modules/axe-core/lib/checks/keyboard/tabindex.js +1 -0
- data/node_modules/axe-core/lib/checks/keyboard/tabindex.json +11 -0
- data/node_modules/axe-core/lib/checks/label/alt-space-value.js +2 -0
- data/node_modules/axe-core/lib/checks/label/alt-space-value.json +11 -0
- data/node_modules/axe-core/lib/checks/label/duplicate-img-label.js +19 -0
- data/node_modules/axe-core/lib/checks/label/duplicate-img-label.json +11 -0
- data/node_modules/axe-core/lib/checks/label/explicit.js +15 -0
- data/node_modules/axe-core/lib/checks/label/explicit.json +11 -0
- data/node_modules/axe-core/lib/checks/label/help-same-as-label.js +23 -0
- data/node_modules/axe-core/lib/checks/label/help-same-as-label.json +12 -0
- data/node_modules/axe-core/lib/checks/label/hidden-explicit-label.js +12 -0
- data/node_modules/axe-core/lib/checks/label/hidden-explicit-label.json +11 -0
- data/node_modules/axe-core/lib/checks/label/implicit.js +7 -0
- data/node_modules/axe-core/lib/checks/label/implicit.json +11 -0
- data/node_modules/axe-core/lib/checks/label/label-content-name-mismatch.js +49 -0
- data/node_modules/axe-core/lib/checks/label/label-content-name-mismatch.json +11 -0
- data/node_modules/axe-core/lib/checks/label/multiple-label.js +29 -0
- data/node_modules/axe-core/lib/checks/label/multiple-label.json +11 -0
- data/node_modules/axe-core/lib/checks/label/title-only.js +5 -0
- data/node_modules/axe-core/lib/checks/label/title-only.json +11 -0
- data/node_modules/axe-core/lib/checks/language/has-lang.js +5 -0
- data/node_modules/axe-core/lib/checks/language/has-lang.json +11 -0
- data/node_modules/axe-core/lib/checks/language/valid-lang.js +26 -0
- data/node_modules/axe-core/lib/checks/language/valid-lang.json +11 -0
- data/node_modules/axe-core/lib/checks/language/xml-lang-mismatch.js +5 -0
- data/node_modules/axe-core/lib/checks/language/xml-lang-mismatch.json +11 -0
- data/node_modules/axe-core/lib/checks/lists/dlitem.js +23 -0
- data/node_modules/axe-core/lib/checks/lists/dlitem.json +11 -0
- data/node_modules/axe-core/lib/checks/lists/listitem.js +18 -0
- data/node_modules/axe-core/lib/checks/lists/listitem.json +11 -0
- data/node_modules/axe-core/lib/checks/lists/only-dlitems.js +42 -0
- data/node_modules/axe-core/lib/checks/lists/only-dlitems.json +11 -0
- data/node_modules/axe-core/lib/checks/lists/only-listitems.js +68 -0
- data/node_modules/axe-core/lib/checks/lists/only-listitems.json +11 -0
- data/node_modules/axe-core/lib/checks/lists/structured-dlitems.js +22 -0
- data/node_modules/axe-core/lib/checks/lists/structured-dlitems.json +11 -0
- data/node_modules/axe-core/lib/checks/media/caption.js +8 -0
- data/node_modules/axe-core/lib/checks/media/caption.json +11 -0
- data/node_modules/axe-core/lib/checks/media/description.js +8 -0
- data/node_modules/axe-core/lib/checks/media/description.json +11 -0
- data/node_modules/axe-core/lib/checks/media/frame-tested.js +28 -0
- data/node_modules/axe-core/lib/checks/media/frame-tested.json +15 -0
- data/node_modules/axe-core/lib/checks/mobile/css-orientation-lock.js +132 -0
- data/node_modules/axe-core/lib/checks/mobile/css-orientation-lock.json +12 -0
- data/node_modules/axe-core/lib/checks/mobile/meta-viewport-large.json +15 -0
- data/node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js +38 -0
- data/node_modules/axe-core/lib/checks/mobile/meta-viewport.json +14 -0
- data/node_modules/axe-core/lib/checks/navigation/header-present.js +4 -0
- data/node_modules/axe-core/lib/checks/navigation/header-present.json +11 -0
- data/node_modules/axe-core/lib/checks/navigation/heading-order-after.js +14 -0
- data/node_modules/axe-core/lib/checks/navigation/heading-order.js +15 -0
- data/node_modules/axe-core/lib/checks/navigation/heading-order.json +12 -0
- data/node_modules/axe-core/lib/checks/navigation/internal-link-present.js +4 -0
- data/node_modules/axe-core/lib/checks/navigation/internal-link-present.json +11 -0
- data/node_modules/axe-core/lib/checks/navigation/landmark.js +3 -0
- data/node_modules/axe-core/lib/checks/navigation/landmark.json +11 -0
- data/node_modules/axe-core/lib/checks/navigation/meta-refresh.js +4 -0
- data/node_modules/axe-core/lib/checks/navigation/meta-refresh.json +11 -0
- data/node_modules/axe-core/lib/checks/navigation/p-as-heading.js +93 -0
- data/node_modules/axe-core/lib/checks/navigation/p-as-heading.json +30 -0
- data/node_modules/axe-core/lib/checks/navigation/region-after.js +1 -0
- data/node_modules/axe-core/lib/checks/navigation/region.js +85 -0
- data/node_modules/axe-core/lib/checks/navigation/region.json +12 -0
- data/node_modules/axe-core/lib/checks/navigation/skip-link.js +5 -0
- data/node_modules/axe-core/lib/checks/navigation/skip-link.json +12 -0
- data/node_modules/axe-core/lib/checks/navigation/unique-frame-title-after.js +9 -0
- data/node_modules/axe-core/lib/checks/navigation/unique-frame-title.js +6 -0
- data/node_modules/axe-core/lib/checks/navigation/unique-frame-title.json +12 -0
- data/node_modules/axe-core/lib/checks/parsing/duplicate-id-active.json +12 -0
- data/node_modules/axe-core/lib/checks/parsing/duplicate-id-after.js +8 -0
- data/node_modules/axe-core/lib/checks/parsing/duplicate-id-aria.json +12 -0
- data/node_modules/axe-core/lib/checks/parsing/duplicate-id.js +17 -0
- data/node_modules/axe-core/lib/checks/parsing/duplicate-id.json +12 -0
- data/node_modules/axe-core/lib/checks/shared/aria-label.js +2 -0
- data/node_modules/axe-core/lib/checks/shared/aria-label.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/aria-labelledby.js +2 -0
- data/node_modules/axe-core/lib/checks/shared/aria-labelledby.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/button-has-visible-text.js +12 -0
- data/node_modules/axe-core/lib/checks/shared/button-has-visible-text.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/doc-has-title.js +2 -0
- data/node_modules/axe-core/lib/checks/shared/doc-has-title.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/exists.js +1 -0
- data/node_modules/axe-core/lib/checks/shared/exists.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/has-alt.js +4 -0
- data/node_modules/axe-core/lib/checks/shared/has-alt.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/has-visible-text.js +1 -0
- data/node_modules/axe-core/lib/checks/shared/has-visible-text.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/is-on-screen.js +4 -0
- data/node_modules/axe-core/lib/checks/shared/is-on-screen.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/non-empty-alt.js +2 -0
- data/node_modules/axe-core/lib/checks/shared/non-empty-alt.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/non-empty-if-present.js +11 -0
- data/node_modules/axe-core/lib/checks/shared/non-empty-if-present.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/non-empty-title.js +2 -0
- data/node_modules/axe-core/lib/checks/shared/non-empty-title.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/non-empty-value.js +2 -0
- data/node_modules/axe-core/lib/checks/shared/non-empty-value.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/role-none.js +1 -0
- data/node_modules/axe-core/lib/checks/shared/role-none.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/role-presentation.js +1 -0
- data/node_modules/axe-core/lib/checks/shared/role-presentation.json +11 -0
- data/node_modules/axe-core/lib/checks/tables/caption-faked.js +10 -0
- data/node_modules/axe-core/lib/checks/tables/caption-faked.json +11 -0
- data/node_modules/axe-core/lib/checks/tables/has-caption.js +1 -0
- data/node_modules/axe-core/lib/checks/tables/has-caption.json +11 -0
- data/node_modules/axe-core/lib/checks/tables/has-summary.js +1 -0
- data/node_modules/axe-core/lib/checks/tables/has-summary.json +11 -0
- data/node_modules/axe-core/lib/checks/tables/has-th.js +31 -0
- data/node_modules/axe-core/lib/checks/tables/has-th.json +11 -0
- data/node_modules/axe-core/lib/checks/tables/headers-visible-text.js +30 -0
- data/node_modules/axe-core/lib/checks/tables/html5-scope.js +5 -0
- data/node_modules/axe-core/lib/checks/tables/html5-scope.json +11 -0
- data/node_modules/axe-core/lib/checks/tables/same-caption-summary.js +7 -0
- data/node_modules/axe-core/lib/checks/tables/same-caption-summary.json +11 -0
- data/node_modules/axe-core/lib/checks/tables/scope-value.js +5 -0
- data/node_modules/axe-core/lib/checks/tables/scope-value.json +11 -0
- data/node_modules/axe-core/lib/checks/tables/td-has-header.js +29 -0
- data/node_modules/axe-core/lib/checks/tables/td-has-header.json +11 -0
- data/node_modules/axe-core/lib/checks/tables/td-headers-attr.js +62 -0
- data/node_modules/axe-core/lib/checks/tables/td-headers-attr.json +11 -0
- data/node_modules/axe-core/lib/checks/tables/th-has-data-cells.js +76 -0
- data/node_modules/axe-core/lib/checks/tables/th-has-data-cells.json +12 -0
- data/node_modules/axe-core/lib/checks/tables/th-single-row-column.js +39 -0
- data/node_modules/axe-core/lib/checks/visibility/hidden-content.js +21 -0
- data/node_modules/axe-core/lib/checks/visibility/hidden-content.json +12 -0
- data/node_modules/axe-core/lib/commons/aria/arialabel-text.js +15 -0
- data/node_modules/axe-core/lib/commons/aria/arialabelledby-text.js +52 -0
- data/node_modules/axe-core/lib/commons/aria/attributes.js +45 -0
- data/node_modules/axe-core/lib/commons/aria/get-element-unallowed-roles.js +92 -0
- data/node_modules/axe-core/lib/commons/aria/get-owned-virtual.js +24 -0
- data/node_modules/axe-core/lib/commons/aria/get-role.js +44 -0
- data/node_modules/axe-core/lib/commons/aria/index.js +2417 -0
- data/node_modules/axe-core/lib/commons/aria/is-accessible-ref.js +55 -0
- data/node_modules/axe-core/lib/commons/aria/is-aria-role-allowed-on-element.js +41 -0
- data/node_modules/axe-core/lib/commons/aria/is-unsupported-role.js +14 -0
- data/node_modules/axe-core/lib/commons/aria/label-virtual.js +54 -0
- data/node_modules/axe-core/lib/commons/aria/named-from-contents.js +39 -0
- data/node_modules/axe-core/lib/commons/aria/roles.js +208 -0
- data/node_modules/axe-core/lib/commons/aria/validate-attr-value.js +63 -0
- data/node_modules/axe-core/lib/commons/color/contrast.js +172 -0
- data/node_modules/axe-core/lib/commons/color/element-is-distinct.js +88 -0
- data/node_modules/axe-core/lib/commons/color/get-background-color.js +411 -0
- data/node_modules/axe-core/lib/commons/color/get-foreground-color.js +32 -0
- data/node_modules/axe-core/lib/commons/color/incomplete-data.js +50 -0
- data/node_modules/axe-core/lib/commons/color/index.js +8 -0
- data/node_modules/axe-core/lib/commons/dom/elements-below-floating.js +39 -0
- data/node_modules/axe-core/lib/commons/dom/find-elms-in-context.js +28 -0
- data/node_modules/axe-core/lib/commons/dom/find-up.js +63 -0
- data/node_modules/axe-core/lib/commons/dom/get-composed-parent.js +25 -0
- data/node_modules/axe-core/lib/commons/dom/get-element-by-reference.js +34 -0
- data/node_modules/axe-core/lib/commons/dom/get-element-coordinates.js +38 -0
- data/node_modules/axe-core/lib/commons/dom/get-root-node.js +12 -0
- data/node_modules/axe-core/lib/commons/dom/get-scroll-offset.js +34 -0
- data/node_modules/axe-core/lib/commons/dom/get-tabbable-elements.js +24 -0
- data/node_modules/axe-core/lib/commons/dom/get-viewport-size.js +37 -0
- data/node_modules/axe-core/lib/commons/dom/has-content-virtual.js +73 -0
- data/node_modules/axe-core/lib/commons/dom/idrefs.js +36 -0
- data/node_modules/axe-core/lib/commons/dom/index.js +9 -0
- data/node_modules/axe-core/lib/commons/dom/is-focusable.js +90 -0
- data/node_modules/axe-core/lib/commons/dom/is-hidden-with-css.js +60 -0
- data/node_modules/axe-core/lib/commons/dom/is-html5.js +17 -0
- data/node_modules/axe-core/lib/commons/dom/is-in-text-block.js +95 -0
- data/node_modules/axe-core/lib/commons/dom/is-node.js +13 -0
- data/node_modules/axe-core/lib/commons/dom/is-offscreen.js +62 -0
- data/node_modules/axe-core/lib/commons/dom/is-visible.js +77 -0
- data/node_modules/axe-core/lib/commons/dom/is-visual-content.js +50 -0
- data/node_modules/axe-core/lib/commons/dom/shadow-elements-from-point.js +41 -0
- data/node_modules/axe-core/lib/commons/dom/visually-contains.js +62 -0
- data/node_modules/axe-core/lib/commons/dom/visually-overlaps.js +47 -0
- data/node_modules/axe-core/lib/commons/index.js +11 -0
- data/node_modules/axe-core/lib/commons/intro.stub +1 -0
- data/node_modules/axe-core/lib/commons/matches/attributes.js +23 -0
- data/node_modules/axe-core/lib/commons/matches/condition.js +19 -0
- data/node_modules/axe-core/lib/commons/matches/from-definition.js +47 -0
- data/node_modules/axe-core/lib/commons/matches/from-function.js +38 -0
- data/node_modules/axe-core/lib/commons/matches/from-primative.js +30 -0
- data/node_modules/axe-core/lib/commons/matches/index.js +37 -0
- data/node_modules/axe-core/lib/commons/matches/node-name.js +34 -0
- data/node_modules/axe-core/lib/commons/matches/properties.js +25 -0
- data/node_modules/axe-core/lib/commons/outro.stub +2 -0
- data/node_modules/axe-core/lib/commons/table/get-all-cells.js +28 -0
- data/node_modules/axe-core/lib/commons/table/get-cell-position.js +28 -0
- data/node_modules/axe-core/lib/commons/table/get-headers.js +29 -0
- data/node_modules/axe-core/lib/commons/table/get-scope.js +54 -0
- data/node_modules/axe-core/lib/commons/table/index.js +9 -0
- data/node_modules/axe-core/lib/commons/table/is-column-header.js +13 -0
- data/node_modules/axe-core/lib/commons/table/is-data-cell.js +22 -0
- data/node_modules/axe-core/lib/commons/table/is-data-table.js +190 -0
- data/node_modules/axe-core/lib/commons/table/is-header.js +22 -0
- data/node_modules/axe-core/lib/commons/table/is-row-header.js +13 -0
- data/node_modules/axe-core/lib/commons/table/to-grid.js +38 -0
- data/node_modules/axe-core/lib/commons/table/traverse.js +78 -0
- data/node_modules/axe-core/lib/commons/text/accessible-text-virtual.js +152 -0
- data/node_modules/axe-core/lib/commons/text/form-control-value.js +204 -0
- data/node_modules/axe-core/lib/commons/text/index.js +8 -0
- data/node_modules/axe-core/lib/commons/text/is-human-interpretable.js +51 -0
- data/node_modules/axe-core/lib/commons/text/is-valid-autocomplete.js +118 -0
- data/node_modules/axe-core/lib/commons/text/label-text.js +58 -0
- data/node_modules/axe-core/lib/commons/text/label-virtual.js +53 -0
- data/node_modules/axe-core/lib/commons/text/native-element-types.js +100 -0
- data/node_modules/axe-core/lib/commons/text/native-text-alternative.js +50 -0
- data/node_modules/axe-core/lib/commons/text/native-text-methods.js +122 -0
- data/node_modules/axe-core/lib/commons/text/sanitize.js +18 -0
- data/node_modules/axe-core/lib/commons/text/subtree-text.js +89 -0
- data/node_modules/axe-core/lib/commons/text/title-text.js +33 -0
- data/node_modules/axe-core/lib/commons/text/unicode.js +117 -0
- data/node_modules/axe-core/lib/commons/text/unsupported.js +5 -0
- data/node_modules/axe-core/lib/commons/text/visible-virtual.js +46 -0
- data/node_modules/axe-core/lib/commons/utils/index.js +10 -0
- data/node_modules/axe-core/lib/core/base/audit.js +684 -0
- data/node_modules/axe-core/lib/core/base/check-result.js +33 -0
- data/node_modules/axe-core/lib/core/base/check.js +123 -0
- data/node_modules/axe-core/lib/core/base/context.js +273 -0
- data/node_modules/axe-core/lib/core/base/rule-result.js +39 -0
- data/node_modules/axe-core/lib/core/base/rule.js +383 -0
- data/node_modules/axe-core/lib/core/constants.js +68 -0
- data/node_modules/axe-core/lib/core/imports/index.js +26 -0
- data/node_modules/axe-core/lib/core/index.js +45 -0
- data/node_modules/axe-core/lib/core/log.js +12 -0
- data/node_modules/axe-core/lib/core/public/cleanup-plugins.js +53 -0
- data/node_modules/axe-core/lib/core/public/configure.js +57 -0
- data/node_modules/axe-core/lib/core/public/get-rules.js +29 -0
- data/node_modules/axe-core/lib/core/public/load.js +66 -0
- data/node_modules/axe-core/lib/core/public/plugins.js +47 -0
- data/node_modules/axe-core/lib/core/public/reporter.js +24 -0
- data/node_modules/axe-core/lib/core/public/reset.js +12 -0
- data/node_modules/axe-core/lib/core/public/run-rules.js +94 -0
- data/node_modules/axe-core/lib/core/public/run.js +148 -0
- data/node_modules/axe-core/lib/core/reporters/helpers/failure-summary.js +35 -0
- data/node_modules/axe-core/lib/core/reporters/helpers/get-environment-data.js +39 -0
- data/node_modules/axe-core/lib/core/reporters/helpers/incomplete-fallback-msg.js +11 -0
- data/node_modules/axe-core/lib/core/reporters/helpers/index.js +3 -0
- data/node_modules/axe-core/lib/core/reporters/helpers/process-aggregate.js +102 -0
- data/node_modules/axe-core/lib/core/reporters/na.js +20 -0
- data/node_modules/axe-core/lib/core/reporters/no-passes.js +18 -0
- data/node_modules/axe-core/lib/core/reporters/raw.js +8 -0
- data/node_modules/axe-core/lib/core/reporters/v1.js +26 -0
- data/node_modules/axe-core/lib/core/reporters/v2.js +22 -0
- data/node_modules/axe-core/lib/core/utils/aggregate.js +19 -0
- data/node_modules/axe-core/lib/core/utils/aggregateChecks.js +85 -0
- data/node_modules/axe-core/lib/core/utils/aggregateNodeResults.js +61 -0
- data/node_modules/axe-core/lib/core/utils/aggregateResult.js +37 -0
- data/node_modules/axe-core/lib/core/utils/are-styles-set.js +24 -0
- data/node_modules/axe-core/lib/core/utils/check-helper.js +38 -0
- data/node_modules/axe-core/lib/core/utils/clone.js +27 -0
- data/node_modules/axe-core/lib/core/utils/collect-results-from-frames.js +127 -0
- data/node_modules/axe-core/lib/core/utils/contains.js +30 -0
- data/node_modules/axe-core/lib/core/utils/css-parser.js +5 -0
- data/node_modules/axe-core/lib/core/utils/dq-element.js +97 -0
- data/node_modules/axe-core/lib/core/utils/element-matches.js +39 -0
- data/node_modules/axe-core/lib/core/utils/escape-selector.js +79 -0
- data/node_modules/axe-core/lib/core/utils/extend-meta-data.js +17 -0
- data/node_modules/axe-core/lib/core/utils/finalize-result.js +11 -0
- data/node_modules/axe-core/lib/core/utils/find-by.js +14 -0
- data/node_modules/axe-core/lib/core/utils/flattened-tree.js +170 -0
- data/node_modules/axe-core/lib/core/utils/get-all-checks.js +12 -0
- data/node_modules/axe-core/lib/core/utils/get-base-lang.js +16 -0
- data/node_modules/axe-core/lib/core/utils/get-check-option.js +40 -0
- data/node_modules/axe-core/lib/core/utils/get-friendly-uri-end.js +144 -0
- data/node_modules/axe-core/lib/core/utils/get-root-node.js +17 -0
- data/node_modules/axe-core/lib/core/utils/get-selector.js +406 -0
- data/node_modules/axe-core/lib/core/utils/get-xpath.js +84 -0
- data/node_modules/axe-core/lib/core/utils/index.js +10 -0
- data/node_modules/axe-core/lib/core/utils/inject-style.js +38 -0
- data/node_modules/axe-core/lib/core/utils/is-hidden.js +40 -0
- data/node_modules/axe-core/lib/core/utils/is-html-element.js +135 -0
- data/node_modules/axe-core/lib/core/utils/is-shadow-root.js +40 -0
- data/node_modules/axe-core/lib/core/utils/is-xhtml.js +14 -0
- data/node_modules/axe-core/lib/core/utils/merge-results.js +116 -0
- data/node_modules/axe-core/lib/core/utils/node-sorter.js +21 -0
- data/node_modules/axe-core/lib/core/utils/performance-timer.js +121 -0
- data/node_modules/axe-core/lib/core/utils/pollyfills.js +299 -0
- data/node_modules/axe-core/lib/core/utils/preload-cssom.js +456 -0
- data/node_modules/axe-core/lib/core/utils/preload.js +109 -0
- data/node_modules/axe-core/lib/core/utils/publish-metadata.js +93 -0
- data/node_modules/axe-core/lib/core/utils/qsa.js +322 -0
- data/node_modules/axe-core/lib/core/utils/queue.js +138 -0
- data/node_modules/axe-core/lib/core/utils/respondable.js +243 -0
- data/node_modules/axe-core/lib/core/utils/rule-should-run.js +83 -0
- data/node_modules/axe-core/lib/core/utils/scroll-state.js +70 -0
- data/node_modules/axe-core/lib/core/utils/select.js +146 -0
- data/node_modules/axe-core/lib/core/utils/to-array.js +21 -0
- data/node_modules/axe-core/lib/core/utils/token-list.js +15 -0
- data/node_modules/axe-core/lib/core/utils/uuid.js +242 -0
- data/node_modules/axe-core/lib/core/utils/valid-input-type.js +35 -0
- data/node_modules/axe-core/lib/core/utils/valid-langs.js +8152 -0
- data/node_modules/axe-core/lib/intro.stub +15 -0
- data/node_modules/axe-core/lib/misc/any-failure-summary.json +6 -0
- data/node_modules/axe-core/lib/misc/incomplete-fallback.json +3 -0
- data/node_modules/axe-core/lib/misc/none-failure-summary.json +6 -0
- data/node_modules/axe-core/lib/outro.stub +2 -0
- data/node_modules/axe-core/lib/rules/accesskeys.json +13 -0
- data/node_modules/axe-core/lib/rules/area-alt.json +19 -0
- data/node_modules/axe-core/lib/rules/aria-allowed-attr-matches.js +11 -0
- data/node_modules/axe-core/lib/rules/aria-allowed-attr.json +12 -0
- data/node_modules/axe-core/lib/rules/aria-allowed-role-matches.js +7 -0
- data/node_modules/axe-core/lib/rules/aria-allowed-role.json +14 -0
- data/node_modules/axe-core/lib/rules/aria-dpub-role-fallback-matches.js +10 -0
- data/node_modules/axe-core/lib/rules/aria-dpub-role-fallback.json +13 -0
- data/node_modules/axe-core/lib/rules/aria-has-attr-matches.js +11 -0
- data/node_modules/axe-core/lib/rules/aria-hidden-body.json +13 -0
- data/node_modules/axe-core/lib/rules/aria-hidden-focus-matches.js +18 -0
- data/node_modules/axe-core/lib/rules/aria-hidden-focus.json +14 -0
- data/node_modules/axe-core/lib/rules/aria-required-attr.json +12 -0
- data/node_modules/axe-core/lib/rules/aria-required-children.json +12 -0
- data/node_modules/axe-core/lib/rules/aria-required-parent.json +12 -0
- data/node_modules/axe-core/lib/rules/aria-roles.json +12 -0
- data/node_modules/axe-core/lib/rules/aria-valid-attr-value.json +12 -0
- data/node_modules/axe-core/lib/rules/aria-valid-attr.json +12 -0
- data/node_modules/axe-core/lib/rules/audio-caption.json +20 -0
- data/node_modules/axe-core/lib/rules/autocomplete-matches.js +45 -0
- data/node_modules/axe-core/lib/rules/autocomplete-valid.json +12 -0
- data/node_modules/axe-core/lib/rules/blink.json +19 -0
- data/node_modules/axe-core/lib/rules/button-name.json +27 -0
- data/node_modules/axe-core/lib/rules/bypass-matches.js +1 -0
- data/node_modules/axe-core/lib/rules/bypass.json +20 -0
- data/node_modules/axe-core/lib/rules/checkboxgroup.json +12 -0
- data/node_modules/axe-core/lib/rules/color-contrast-matches.js +120 -0
- data/node_modules/axe-core/lib/rules/color-contrast.json +16 -0
- data/node_modules/axe-core/lib/rules/css-orientation-lock.json +13 -0
- data/node_modules/axe-core/lib/rules/data-table-large-matches.js +11 -0
- data/node_modules/axe-core/lib/rules/data-table-matches.js +1 -0
- data/node_modules/axe-core/lib/rules/definition-list.json +13 -0
- data/node_modules/axe-core/lib/rules/dlitem.json +13 -0
- data/node_modules/axe-core/lib/rules/document-title.json +13 -0
- data/node_modules/axe-core/lib/rules/duplicate-id-active-matches.js +8 -0
- data/node_modules/axe-core/lib/rules/duplicate-id-active.json +14 -0
- data/node_modules/axe-core/lib/rules/duplicate-id-aria-matches.js +1 -0
- data/node_modules/axe-core/lib/rules/duplicate-id-aria.json +14 -0
- data/node_modules/axe-core/lib/rules/duplicate-id-misc-matches.js +11 -0
- data/node_modules/axe-core/lib/rules/duplicate-id.json +14 -0
- data/node_modules/axe-core/lib/rules/empty-heading.json +13 -0
- data/node_modules/axe-core/lib/rules/focus-order-semantics.json +13 -0
- data/node_modules/axe-core/lib/rules/form-field-multiple-labels.json +13 -0
- data/node_modules/axe-core/lib/rules/frame-tested.json +12 -0
- data/node_modules/axe-core/lib/rules/frame-title-has-text.js +2 -0
- data/node_modules/axe-core/lib/rules/frame-title-unique.json +13 -0
- data/node_modules/axe-core/lib/rules/frame-title.json +25 -0
- data/node_modules/axe-core/lib/rules/heading-matches.js +15 -0
- data/node_modules/axe-core/lib/rules/heading-order.json +13 -0
- data/node_modules/axe-core/lib/rules/hidden-content.json +13 -0
- data/node_modules/axe-core/lib/rules/html-has-lang.json +12 -0
- data/node_modules/axe-core/lib/rules/html-lang-valid.json +12 -0
- data/node_modules/axe-core/lib/rules/html-xml-lang-mismatch.json +13 -0
- data/node_modules/axe-core/lib/rules/image-alt.json +25 -0
- data/node_modules/axe-core/lib/rules/img-redundant-alt.json +12 -0
- data/node_modules/axe-core/lib/rules/input-image-alt.json +18 -0
- data/node_modules/axe-core/lib/rules/inserted-into-focus-order-matches.js +1 -0
- data/node_modules/axe-core/lib/rules/label-content-name-mismatch-matches.js +42 -0
- data/node_modules/axe-core/lib/rules/label-content-name-mismatch.json +12 -0
- data/node_modules/axe-core/lib/rules/label-matches.js +11 -0
- data/node_modules/axe-core/lib/rules/label-title-only.json +13 -0
- data/node_modules/axe-core/lib/rules/label.json +26 -0
- data/node_modules/axe-core/lib/rules/landmark-banner-is-top-level.json +13 -0
- data/node_modules/axe-core/lib/rules/landmark-complementary-is-top-level.json +12 -0
- data/node_modules/axe-core/lib/rules/landmark-contentinfo-is-top-level.json +13 -0
- data/node_modules/axe-core/lib/rules/landmark-has-body-context.js +8 -0
- data/node_modules/axe-core/lib/rules/landmark-main-is-top-level.json +12 -0
- data/node_modules/axe-core/lib/rules/landmark-no-duplicate-banner.json +12 -0
- data/node_modules/axe-core/lib/rules/landmark-no-duplicate-contentinfo.json +12 -0
- data/node_modules/axe-core/lib/rules/landmark-one-main.json +12 -0
- data/node_modules/axe-core/lib/rules/layout-table-matches.js +8 -0
- data/node_modules/axe-core/lib/rules/layout-table.json +13 -0
- data/node_modules/axe-core/lib/rules/link-in-text-block-matches.js +14 -0
- data/node_modules/axe-core/lib/rules/link-in-text-block.json +14 -0
- data/node_modules/axe-core/lib/rules/link-name.json +26 -0
- data/node_modules/axe-core/lib/rules/list.json +13 -0
- data/node_modules/axe-core/lib/rules/listitem.json +13 -0
- data/node_modules/axe-core/lib/rules/marquee.json +13 -0
- data/node_modules/axe-core/lib/rules/meta-refresh.json +13 -0
- data/node_modules/axe-core/lib/rules/meta-viewport-large.json +13 -0
- data/node_modules/axe-core/lib/rules/meta-viewport.json +13 -0
- data/node_modules/axe-core/lib/rules/no-role-matches.js +1 -0
- data/node_modules/axe-core/lib/rules/not-html-matches.js +1 -0
- data/node_modules/axe-core/lib/rules/object-alt.json +25 -0
- data/node_modules/axe-core/lib/rules/p-as-heading-matches.js +17 -0
- data/node_modules/axe-core/lib/rules/p-as-heading.json +13 -0
- data/node_modules/axe-core/lib/rules/page-has-heading-one.json +12 -0
- data/node_modules/axe-core/lib/rules/radiogroup.json +12 -0
- data/node_modules/axe-core/lib/rules/region.json +13 -0
- data/node_modules/axe-core/lib/rules/role-not-button-matches.js +1 -0
- data/node_modules/axe-core/lib/rules/scope-attr-valid.json +12 -0
- data/node_modules/axe-core/lib/rules/server-side-image-map.json +18 -0
- data/node_modules/axe-core/lib/rules/skip-link-matches.js +1 -0
- data/node_modules/axe-core/lib/rules/skip-link.json +13 -0
- data/node_modules/axe-core/lib/rules/tabindex.json +12 -0
- data/node_modules/axe-core/lib/rules/table-duplicate-name.json +12 -0
- data/node_modules/axe-core/lib/rules/table-fake-caption.json +20 -0
- data/node_modules/axe-core/lib/rules/td-has-header.json +20 -0
- data/node_modules/axe-core/lib/rules/td-headers-attr.json +12 -0
- data/node_modules/axe-core/lib/rules/th-has-data-cells.json +13 -0
- data/node_modules/axe-core/lib/rules/valid-lang.json +13 -0
- data/node_modules/axe-core/lib/rules/video-caption.json +19 -0
- data/node_modules/axe-core/lib/rules/video-description.json +19 -0
- data/node_modules/axe-core/lib/rules/window-is-top.js +3 -0
- data/node_modules/axe-core/lib/rules/xml-lang-mismatch-matches.js +12 -0
- data/node_modules/axe-core/locales/de.json +627 -0
- data/node_modules/axe-core/locales/fr.json +667 -0
- data/node_modules/axe-core/locales/ja.json +728 -0
- data/node_modules/axe-core/locales/nl.json +36 -0
- data/node_modules/axe-core/package.json +215 -0
- data/node_modules/axe-core/sri-history.json +138 -0
- data/node_modules/axe-core/typings/axe-core/axe-core-tests.ts +180 -0
- metadata +511 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/* global color */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @class Color
|
|
5
|
+
* @memberof axe.commons.color
|
|
6
|
+
* @param {number} red
|
|
7
|
+
* @param {number} green
|
|
8
|
+
* @param {number} blue
|
|
9
|
+
* @param {number} alpha
|
|
10
|
+
*/
|
|
11
|
+
color.Color = function(red, green, blue, alpha) {
|
|
12
|
+
/** @type {number} */
|
|
13
|
+
this.red = red;
|
|
14
|
+
|
|
15
|
+
/** @type {number} */
|
|
16
|
+
this.green = green;
|
|
17
|
+
|
|
18
|
+
/** @type {number} */
|
|
19
|
+
this.blue = blue;
|
|
20
|
+
|
|
21
|
+
/** @type {number} */
|
|
22
|
+
this.alpha = alpha;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Provide the hex string value for the color
|
|
26
|
+
* @method toHexString
|
|
27
|
+
* @memberof axe.commons.color.Color
|
|
28
|
+
* @instance
|
|
29
|
+
* @return {string}
|
|
30
|
+
*/
|
|
31
|
+
this.toHexString = function() {
|
|
32
|
+
var redString = Math.round(this.red).toString(16);
|
|
33
|
+
var greenString = Math.round(this.green).toString(16);
|
|
34
|
+
var blueString = Math.round(this.blue).toString(16);
|
|
35
|
+
return (
|
|
36
|
+
'#' +
|
|
37
|
+
(this.red > 15.5 ? redString : '0' + redString) +
|
|
38
|
+
(this.green > 15.5 ? greenString : '0' + greenString) +
|
|
39
|
+
(this.blue > 15.5 ? blueString : '0' + blueString)
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var rgbRegex = /^rgb\((\d+), (\d+), (\d+)\)$/;
|
|
44
|
+
var rgbaRegex = /^rgba\((\d+), (\d+), (\d+), (\d*(\.\d+)?)\)/;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Set the color value based on a CSS RGB/RGBA string
|
|
48
|
+
* @method parseRgbString
|
|
49
|
+
* @memberof axe.commons.color.Color
|
|
50
|
+
* @instance
|
|
51
|
+
* @param {string} rgb The string value
|
|
52
|
+
*/
|
|
53
|
+
this.parseRgbString = function(colorString) {
|
|
54
|
+
// IE can pass transparent as value instead of rgba
|
|
55
|
+
if (colorString === 'transparent') {
|
|
56
|
+
this.red = 0;
|
|
57
|
+
this.green = 0;
|
|
58
|
+
this.blue = 0;
|
|
59
|
+
this.alpha = 0;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
var match = colorString.match(rgbRegex);
|
|
63
|
+
|
|
64
|
+
if (match) {
|
|
65
|
+
this.red = parseInt(match[1], 10);
|
|
66
|
+
this.green = parseInt(match[2], 10);
|
|
67
|
+
this.blue = parseInt(match[3], 10);
|
|
68
|
+
this.alpha = 1;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
match = colorString.match(rgbaRegex);
|
|
73
|
+
if (match) {
|
|
74
|
+
this.red = parseInt(match[1], 10);
|
|
75
|
+
this.green = parseInt(match[2], 10);
|
|
76
|
+
this.blue = parseInt(match[3], 10);
|
|
77
|
+
this.alpha = parseFloat(match[4]);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get the relative luminance value
|
|
84
|
+
* using algorithm from http://www.w3.org/WAI/GL/wiki/Relative_luminance
|
|
85
|
+
* @method getRelativeLuminance
|
|
86
|
+
* @memberof axe.commons.color.Color
|
|
87
|
+
* @instance
|
|
88
|
+
* @return {number} The luminance value, ranges from 0 to 1
|
|
89
|
+
*/
|
|
90
|
+
this.getRelativeLuminance = function() {
|
|
91
|
+
var rSRGB = this.red / 255;
|
|
92
|
+
var gSRGB = this.green / 255;
|
|
93
|
+
var bSRGB = this.blue / 255;
|
|
94
|
+
|
|
95
|
+
var r =
|
|
96
|
+
rSRGB <= 0.03928 ? rSRGB / 12.92 : Math.pow((rSRGB + 0.055) / 1.055, 2.4);
|
|
97
|
+
var g =
|
|
98
|
+
gSRGB <= 0.03928 ? gSRGB / 12.92 : Math.pow((gSRGB + 0.055) / 1.055, 2.4);
|
|
99
|
+
var b =
|
|
100
|
+
bSRGB <= 0.03928 ? bSRGB / 12.92 : Math.pow((bSRGB + 0.055) / 1.055, 2.4);
|
|
101
|
+
|
|
102
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Combine the two given color according to alpha blending.
|
|
108
|
+
* @method flattenColors
|
|
109
|
+
* @memberof axe.commons.color.Color
|
|
110
|
+
* @instance
|
|
111
|
+
* @param {Color} fgColor Foreground color
|
|
112
|
+
* @param {Color} bgColor Background color
|
|
113
|
+
* @return {Color} Blended color
|
|
114
|
+
*/
|
|
115
|
+
color.flattenColors = function(fgColor, bgColor) {
|
|
116
|
+
var alpha = fgColor.alpha;
|
|
117
|
+
var r = (1 - alpha) * bgColor.red + alpha * fgColor.red;
|
|
118
|
+
var g = (1 - alpha) * bgColor.green + alpha * fgColor.green;
|
|
119
|
+
var b = (1 - alpha) * bgColor.blue + alpha * fgColor.blue;
|
|
120
|
+
var a = fgColor.alpha + bgColor.alpha * (1 - fgColor.alpha);
|
|
121
|
+
|
|
122
|
+
return new color.Color(r, g, b, a);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get the contrast of two colors
|
|
127
|
+
* @method getContrast
|
|
128
|
+
* @memberof axe.commons.color.Color
|
|
129
|
+
* @instance
|
|
130
|
+
* @param {Color} bgcolor Background color
|
|
131
|
+
* @param {Color} fgcolor Foreground color
|
|
132
|
+
* @return {number} The contrast ratio
|
|
133
|
+
*/
|
|
134
|
+
color.getContrast = function(bgColor, fgColor) {
|
|
135
|
+
if (!fgColor || !bgColor) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (fgColor.alpha < 1) {
|
|
140
|
+
fgColor = color.flattenColors(fgColor, bgColor);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
var bL = bgColor.getRelativeLuminance();
|
|
144
|
+
var fL = fgColor.getRelativeLuminance();
|
|
145
|
+
|
|
146
|
+
return (Math.max(fL, bL) + 0.05) / (Math.min(fL, bL) + 0.05);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Check whether certain text properties meet WCAG contrast rules
|
|
151
|
+
* @method hasValidContrastRatio
|
|
152
|
+
* @memberof axe.commons.color.Color
|
|
153
|
+
* @instance
|
|
154
|
+
* @param {Color} bgcolor Background color
|
|
155
|
+
* @param {Color} fgcolor Foreground color
|
|
156
|
+
* @param {number} fontSize Font size of text, in pixels
|
|
157
|
+
* @param {boolean} isBold Whether the text is bold
|
|
158
|
+
* @return {{isValid: boolean, contrastRatio: number, expectedContrastRatio: number}}
|
|
159
|
+
*/
|
|
160
|
+
color.hasValidContrastRatio = function(bg, fg, fontSize, isBold) {
|
|
161
|
+
var contrast = color.getContrast(bg, fg);
|
|
162
|
+
var isSmallFont =
|
|
163
|
+
(isBold && Math.ceil(fontSize * 72) / 96 < 14) ||
|
|
164
|
+
(!isBold && Math.ceil(fontSize * 72) / 96 < 18);
|
|
165
|
+
var expectedContrastRatio = isSmallFont ? 4.5 : 3;
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
isValid: contrast > expectedContrastRatio,
|
|
169
|
+
contrastRatio: contrast,
|
|
170
|
+
expectedContrastRatio: expectedContrastRatio
|
|
171
|
+
};
|
|
172
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/* global color */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a string array of fonts for given CSSStyleDeclaration object
|
|
5
|
+
* @private
|
|
6
|
+
* @param {Object} style CSSStyleDeclaration object
|
|
7
|
+
* @return {Array}
|
|
8
|
+
*/
|
|
9
|
+
function _getFonts(style) {
|
|
10
|
+
return style
|
|
11
|
+
.getPropertyValue('font-family')
|
|
12
|
+
.split(/[,;]/g)
|
|
13
|
+
.map(function(font) {
|
|
14
|
+
return font.trim().toLowerCase();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Determine if the text content of two nodes is styled in a way that they can be distinguished without relying on color
|
|
20
|
+
* @method elementIsDistinct
|
|
21
|
+
* @memberof axe.commons.color
|
|
22
|
+
* @instance
|
|
23
|
+
* @param {HTMLElement} node The element to check
|
|
24
|
+
* @param {HTMLElement} ancestorNode The ancestor node element to check
|
|
25
|
+
* @return {Boolean}
|
|
26
|
+
*/
|
|
27
|
+
function elementIsDistinct(node, ancestorNode) {
|
|
28
|
+
var nodeStyle = window.getComputedStyle(node);
|
|
29
|
+
|
|
30
|
+
// Check if the link has a background
|
|
31
|
+
if (nodeStyle.getPropertyValue('background-image') !== 'none') {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Check if the link has a border or outline
|
|
36
|
+
var hasBorder = ['border-bottom', 'border-top', 'outline'].reduce(function(
|
|
37
|
+
result,
|
|
38
|
+
edge
|
|
39
|
+
) {
|
|
40
|
+
var borderClr = new color.Color();
|
|
41
|
+
borderClr.parseRgbString(nodeStyle.getPropertyValue(edge + '-color'));
|
|
42
|
+
|
|
43
|
+
// Check if a border/outline was specified
|
|
44
|
+
return (
|
|
45
|
+
result ||
|
|
46
|
+
// or if the current border edge / outline
|
|
47
|
+
(nodeStyle.getPropertyValue(edge + '-style') !== 'none' &&
|
|
48
|
+
parseFloat(nodeStyle.getPropertyValue(edge + '-width')) > 0 &&
|
|
49
|
+
borderClr.alpha !== 0)
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
false);
|
|
53
|
+
|
|
54
|
+
if (hasBorder) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var parentStyle = window.getComputedStyle(ancestorNode);
|
|
59
|
+
// Compare fonts
|
|
60
|
+
if (_getFonts(nodeStyle)[0] !== _getFonts(parentStyle)[0]) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var hasStyle = [
|
|
65
|
+
'text-decoration-line',
|
|
66
|
+
'text-decoration-style',
|
|
67
|
+
'font-weight',
|
|
68
|
+
'font-style',
|
|
69
|
+
'font-size'
|
|
70
|
+
].reduce(function(result, cssProp) {
|
|
71
|
+
return (
|
|
72
|
+
result ||
|
|
73
|
+
nodeStyle.getPropertyValue(cssProp) !==
|
|
74
|
+
parentStyle.getPropertyValue(cssProp)
|
|
75
|
+
);
|
|
76
|
+
}, false);
|
|
77
|
+
|
|
78
|
+
var tDec = nodeStyle.getPropertyValue('text-decoration');
|
|
79
|
+
if (tDec.split(' ').length < 3) {
|
|
80
|
+
// old style CSS text decoration
|
|
81
|
+
hasStyle =
|
|
82
|
+
hasStyle || tDec !== parentStyle.getPropertyValue('text-decoration');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return hasStyle;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
color.elementIsDistinct = elementIsDistinct;
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
/* global axe, color, dom */
|
|
2
|
+
const graphicNodes = ['IMG', 'CANVAS', 'OBJECT', 'IFRAME', 'VIDEO', 'SVG'];
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Reports if an element has a background image or gradient
|
|
6
|
+
* @private
|
|
7
|
+
* @param {Element} elm
|
|
8
|
+
* @param {Object|null} style
|
|
9
|
+
* @return {Boolean}
|
|
10
|
+
*/
|
|
11
|
+
function elmHasImage(elm, style) {
|
|
12
|
+
var nodeName = elm.nodeName.toUpperCase();
|
|
13
|
+
if (graphicNodes.includes(nodeName)) {
|
|
14
|
+
axe.commons.color.incompleteData.set('bgColor', 'imgNode');
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
style = style || window.getComputedStyle(elm);
|
|
19
|
+
var bgImageStyle = style.getPropertyValue('background-image');
|
|
20
|
+
var hasBgImage = bgImageStyle !== 'none';
|
|
21
|
+
if (hasBgImage) {
|
|
22
|
+
var hasGradient = /gradient/.test(bgImageStyle);
|
|
23
|
+
axe.commons.color.incompleteData.set(
|
|
24
|
+
'bgColor',
|
|
25
|
+
hasGradient ? 'bgGradient' : 'bgImage'
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return hasBgImage;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns the non-alpha-blended background color of an element
|
|
33
|
+
* @private
|
|
34
|
+
* @param {Element} elm
|
|
35
|
+
* @return {Color}
|
|
36
|
+
*/
|
|
37
|
+
function getBgColor(elm, elmStyle) {
|
|
38
|
+
elmStyle = elmStyle || window.getComputedStyle(elm);
|
|
39
|
+
|
|
40
|
+
let bgColor = new color.Color();
|
|
41
|
+
bgColor.parseRgbString(elmStyle.getPropertyValue('background-color'));
|
|
42
|
+
|
|
43
|
+
if (bgColor.alpha !== 0) {
|
|
44
|
+
let opacity = elmStyle.getPropertyValue('opacity');
|
|
45
|
+
bgColor.alpha = bgColor.alpha * opacity;
|
|
46
|
+
}
|
|
47
|
+
return bgColor;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Determines overlap of node's content with a bgNode. Used for inline elements
|
|
52
|
+
* @private
|
|
53
|
+
* @param {Element} targetElement
|
|
54
|
+
* @param {Element} bgNode
|
|
55
|
+
* @return {Boolean}
|
|
56
|
+
*/
|
|
57
|
+
function contentOverlapping(targetElement, bgNode) {
|
|
58
|
+
// get content box of target element
|
|
59
|
+
// check to see if the current bgNode is overlapping
|
|
60
|
+
var targetRect = targetElement.getClientRects()[0];
|
|
61
|
+
var obscuringElements = dom.shadowElementsFromPoint(
|
|
62
|
+
targetRect.left,
|
|
63
|
+
targetRect.top
|
|
64
|
+
);
|
|
65
|
+
if (obscuringElements) {
|
|
66
|
+
for (var i = 0; i < obscuringElements.length; i++) {
|
|
67
|
+
if (
|
|
68
|
+
obscuringElements[i] !== targetElement &&
|
|
69
|
+
obscuringElements[i] === bgNode
|
|
70
|
+
) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Calculate alpha transparency of a background element obscuring the current node
|
|
79
|
+
* @private
|
|
80
|
+
* @param {Number} elmIndex
|
|
81
|
+
* @param {Array} elmStack
|
|
82
|
+
* @param {Element} originalElm
|
|
83
|
+
* @return {Number|undefined}
|
|
84
|
+
*/
|
|
85
|
+
function calculateObscuringAlpha(elmIndex, elmStack, originalElm) {
|
|
86
|
+
var totalAlpha = 0;
|
|
87
|
+
|
|
88
|
+
if (elmIndex > 0) {
|
|
89
|
+
// there are elements above our element, check if they contribute to the background
|
|
90
|
+
for (var i = elmIndex - 1; i >= 0; i--) {
|
|
91
|
+
let bgElm = elmStack[i];
|
|
92
|
+
let bgElmStyle = window.getComputedStyle(bgElm);
|
|
93
|
+
let bgColor = getBgColor(bgElm, bgElmStyle);
|
|
94
|
+
if (bgColor.alpha && contentOverlapping(originalElm, bgElm)) {
|
|
95
|
+
totalAlpha += bgColor.alpha;
|
|
96
|
+
} else {
|
|
97
|
+
// remove elements not contributing to the background
|
|
98
|
+
elmStack.splice(i, 1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return totalAlpha;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Determine if element is partially overlapped, triggering a Can't Tell result
|
|
106
|
+
* @private
|
|
107
|
+
* @param {Element} elm
|
|
108
|
+
* @param {Element} bgElm
|
|
109
|
+
* @param {Object} bgColor
|
|
110
|
+
* @return {Boolean}
|
|
111
|
+
*/
|
|
112
|
+
function elmPartiallyObscured(elm, bgElm, bgColor) {
|
|
113
|
+
var obscured =
|
|
114
|
+
elm !== bgElm && !dom.visuallyContains(elm, bgElm) && bgColor.alpha !== 0;
|
|
115
|
+
if (obscured) {
|
|
116
|
+
axe.commons.color.incompleteData.set('bgColor', 'elmPartiallyObscured');
|
|
117
|
+
}
|
|
118
|
+
return obscured;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Include nodes missing from initial gathering because
|
|
123
|
+
* document.elementsFromPoint misses some elements we need
|
|
124
|
+
* i.e. TR is missing from table elementStack and leaves out bgColor
|
|
125
|
+
* https://github.com/dequelabs/axe-core/issues/273
|
|
126
|
+
*
|
|
127
|
+
* @private
|
|
128
|
+
* @param {Array} elmStack
|
|
129
|
+
* @param {Element} elm
|
|
130
|
+
*/
|
|
131
|
+
function includeMissingElements(elmStack, elm) {
|
|
132
|
+
/*eslint max-depth:["error",7]*/
|
|
133
|
+
const elementMap = {
|
|
134
|
+
TD: ['TR', 'TBODY'],
|
|
135
|
+
TH: ['TR', 'THEAD'],
|
|
136
|
+
INPUT: ['LABEL']
|
|
137
|
+
};
|
|
138
|
+
const tagArray = elmStack.map(elm => {
|
|
139
|
+
return elm.nodeName;
|
|
140
|
+
});
|
|
141
|
+
let bgNodes = elmStack;
|
|
142
|
+
for (let candidate in elementMap) {
|
|
143
|
+
// check that TR or LABEL has paired nodeName from elementMap, but don't expect elm to be that candidate
|
|
144
|
+
if (tagArray.includes(candidate)) {
|
|
145
|
+
for (let candidateIndex in elementMap[candidate]) {
|
|
146
|
+
if (candidate.hasOwnProperty(candidateIndex)) {
|
|
147
|
+
// look up the tree for a matching candidate
|
|
148
|
+
let ancestorMatch = axe.commons.dom.findUp(
|
|
149
|
+
elm,
|
|
150
|
+
elementMap[candidate][candidateIndex]
|
|
151
|
+
);
|
|
152
|
+
if (ancestorMatch && elmStack.indexOf(ancestorMatch) === -1) {
|
|
153
|
+
// found an ancestor not in elmStack, and it overlaps
|
|
154
|
+
let overlaps = axe.commons.dom.visuallyOverlaps(
|
|
155
|
+
elm.getBoundingClientRect(),
|
|
156
|
+
ancestorMatch
|
|
157
|
+
);
|
|
158
|
+
if (overlaps) {
|
|
159
|
+
// if target is in the elementMap, use its position.
|
|
160
|
+
bgNodes.splice(tagArray.indexOf(candidate) + 1, 0, ancestorMatch);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// nodeName matches value
|
|
164
|
+
// (such as LABEL, when matching itself. It should be in the list, but Phantom skips it)
|
|
165
|
+
if (
|
|
166
|
+
elm.nodeName === elementMap[candidate][candidateIndex] &&
|
|
167
|
+
tagArray.indexOf(elm.nodeName) === -1
|
|
168
|
+
) {
|
|
169
|
+
bgNodes.splice(tagArray.indexOf(candidate) + 1, 0, elm);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return bgNodes;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Look at document and body elements for relevant background information
|
|
180
|
+
* @private
|
|
181
|
+
* @param {Array} elmStack
|
|
182
|
+
*/
|
|
183
|
+
function sortPageBackground(elmStack) {
|
|
184
|
+
let bodyIndex = elmStack.indexOf(document.body);
|
|
185
|
+
|
|
186
|
+
let bgNodes = elmStack;
|
|
187
|
+
|
|
188
|
+
if (
|
|
189
|
+
// Check that the body background is the page's background
|
|
190
|
+
bodyIndex > 1 && // only if there are negative z-index elements
|
|
191
|
+
!elmHasImage(document.documentElement) &&
|
|
192
|
+
getBgColor(document.documentElement).alpha === 0
|
|
193
|
+
) {
|
|
194
|
+
// Remove body and html from it's current place
|
|
195
|
+
bgNodes.splice(bodyIndex, 1);
|
|
196
|
+
bgNodes.splice(elmStack.indexOf(document.documentElement), 1);
|
|
197
|
+
|
|
198
|
+
// Put the body background as the lowest element
|
|
199
|
+
bgNodes.push(document.body);
|
|
200
|
+
}
|
|
201
|
+
return bgNodes;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get coordinates for an element's client rects or bounding client rect
|
|
205
|
+
* @method getCoords
|
|
206
|
+
* @memberof axe.commons.color
|
|
207
|
+
* @instance
|
|
208
|
+
* @param {DOMRect} rect
|
|
209
|
+
* @return {Object}
|
|
210
|
+
*/
|
|
211
|
+
color.getCoords = function(rect) {
|
|
212
|
+
let x, y;
|
|
213
|
+
if (rect.left > window.innerWidth) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (rect.top > window.innerHeight) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
x = Math.min(Math.ceil(rect.left + rect.width / 2), window.innerWidth - 1);
|
|
220
|
+
y = Math.min(Math.ceil(rect.top + rect.height / 2), window.innerHeight - 1);
|
|
221
|
+
|
|
222
|
+
return { x, y };
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Get relevant stacks of block and inline elements, excluding line breaks
|
|
226
|
+
* @method getRectStack
|
|
227
|
+
* @memberof axe.commons.color
|
|
228
|
+
* @instance
|
|
229
|
+
* @param {Element} elm
|
|
230
|
+
* @return {Array}
|
|
231
|
+
*/
|
|
232
|
+
color.getRectStack = function(elm) {
|
|
233
|
+
let boundingCoords = color.getCoords(elm.getBoundingClientRect());
|
|
234
|
+
if (!boundingCoords) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
let boundingStack = dom.shadowElementsFromPoint(
|
|
239
|
+
boundingCoords.x,
|
|
240
|
+
boundingCoords.y
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
let rects = Array.from(elm.getClientRects());
|
|
244
|
+
// If the element does not have multiple rects, like for display:block, return a single stack
|
|
245
|
+
if (!rects || rects.length <= 1) {
|
|
246
|
+
return [boundingStack];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Handle inline elements spanning multiple lines to be evaluated
|
|
250
|
+
let filteredArr = rects
|
|
251
|
+
.filter(rect => {
|
|
252
|
+
// exclude manual line breaks in Chrome/Safari
|
|
253
|
+
return rect.width && rect.width > 0;
|
|
254
|
+
})
|
|
255
|
+
.map(rect => {
|
|
256
|
+
let coords = color.getCoords(rect);
|
|
257
|
+
if (coords) {
|
|
258
|
+
return dom.shadowElementsFromPoint(coords.x, coords.y);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
if (filteredArr.some(stack => stack === undefined)) {
|
|
263
|
+
// Can be happen when one or more of the rects sits outside the viewport
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// add bounding client rect stack for comparison later
|
|
268
|
+
filteredArr.splice(0, 0, boundingStack);
|
|
269
|
+
return filteredArr;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Get filtered stack of block and inline elements, excluding line breaks
|
|
273
|
+
* @method filteredRectStack
|
|
274
|
+
* @memberof axe.commons.color
|
|
275
|
+
* @instance
|
|
276
|
+
* @param {Element} elm
|
|
277
|
+
* @return {Array}
|
|
278
|
+
*/
|
|
279
|
+
color.filteredRectStack = function(elm) {
|
|
280
|
+
let rectStack = color.getRectStack(elm);
|
|
281
|
+
if (rectStack && rectStack.length === 1) {
|
|
282
|
+
// default case, elm.getBoundingClientRect()
|
|
283
|
+
return rectStack[0];
|
|
284
|
+
} else if (rectStack && rectStack.length > 1) {
|
|
285
|
+
let boundingStack = rectStack.shift();
|
|
286
|
+
let isSame;
|
|
287
|
+
// iterating over arrays of DOMRects
|
|
288
|
+
rectStack.forEach((rectList, index) => {
|
|
289
|
+
if (index === 0) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
// if the stacks are the same, use the first one. otherwise, return null.
|
|
293
|
+
let rectA = rectStack[index - 1],
|
|
294
|
+
rectB = rectStack[index];
|
|
295
|
+
|
|
296
|
+
// if elements in clientRects are the same
|
|
297
|
+
// or the boundingClientRect contains the differing element, pass it
|
|
298
|
+
isSame =
|
|
299
|
+
rectA.every(function(element, elementIndex) {
|
|
300
|
+
return element === rectB[elementIndex];
|
|
301
|
+
}) || boundingStack.includes(elm);
|
|
302
|
+
});
|
|
303
|
+
if (!isSame) {
|
|
304
|
+
axe.commons.color.incompleteData.set('bgColor', 'elmPartiallyObscuring');
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
// pass the first stack if it wasn't partially covered
|
|
308
|
+
return rectStack[0];
|
|
309
|
+
} else {
|
|
310
|
+
// rect outside of viewport
|
|
311
|
+
axe.commons.color.incompleteData.set('bgColor', 'outsideViewport');
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Get all elements rendered underneath the current element, In the order they are displayed (front to back)
|
|
317
|
+
* @method getBackgroundStack
|
|
318
|
+
* @memberof axe.commons.color
|
|
319
|
+
* @instance
|
|
320
|
+
* @param {Element} elm
|
|
321
|
+
* @return {Array}
|
|
322
|
+
*/
|
|
323
|
+
color.getBackgroundStack = function(elm) {
|
|
324
|
+
let elmStack = color.filteredRectStack(elm);
|
|
325
|
+
if (elmStack === null) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
elmStack = includeMissingElements(elmStack, elm);
|
|
329
|
+
elmStack = dom.reduceToElementsBelowFloating(elmStack, elm);
|
|
330
|
+
elmStack = sortPageBackground(elmStack);
|
|
331
|
+
|
|
332
|
+
// Return all elements BELOW the current element, null if the element is undefined
|
|
333
|
+
let elmIndex = elmStack.indexOf(elm);
|
|
334
|
+
if (calculateObscuringAlpha(elmIndex, elmStack, elm) >= 0.99) {
|
|
335
|
+
// if the total of the elements above our element results in total obscuring, return null
|
|
336
|
+
axe.commons.color.incompleteData.set('bgColor', 'bgOverlap');
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
return elmIndex !== -1 ? elmStack : null;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Returns background color for element
|
|
344
|
+
* Uses color.getBackgroundStack() to get all elements rendered underneath the current element to
|
|
345
|
+
* help determine the background color.
|
|
346
|
+
* @param {Element} elm Element to determine background color
|
|
347
|
+
* @param {Array} [bgElms=[]] [description]
|
|
348
|
+
* @param {Boolean} [noScroll=false] [description]
|
|
349
|
+
* @return {Color} [description]
|
|
350
|
+
*/
|
|
351
|
+
color.getBackgroundColor = function(elm, bgElms = [], noScroll = false) {
|
|
352
|
+
if (noScroll !== true) {
|
|
353
|
+
// Avoid scrolling overflow:hidden containers, by only aligning to top
|
|
354
|
+
// when not doing so would move the center point above the viewport top.
|
|
355
|
+
const clientHeight = elm.getBoundingClientRect().height;
|
|
356
|
+
const alignToTop = clientHeight - 2 >= window.innerHeight * 2;
|
|
357
|
+
elm.scrollIntoView(alignToTop);
|
|
358
|
+
}
|
|
359
|
+
let bgColors = [];
|
|
360
|
+
let elmStack = color.getBackgroundStack(elm);
|
|
361
|
+
|
|
362
|
+
// Search the stack until we have an alpha === 1 background
|
|
363
|
+
(elmStack || []).some(bgElm => {
|
|
364
|
+
let bgElmStyle = window.getComputedStyle(bgElm);
|
|
365
|
+
|
|
366
|
+
// Get the background color
|
|
367
|
+
let bgColor = getBgColor(bgElm, bgElmStyle);
|
|
368
|
+
|
|
369
|
+
if (
|
|
370
|
+
// abort if a node is partially obscured and obscuring element has a background
|
|
371
|
+
elmPartiallyObscured(elm, bgElm, bgColor) ||
|
|
372
|
+
// OR if the background elm is a graphic
|
|
373
|
+
elmHasImage(bgElm, bgElmStyle)
|
|
374
|
+
) {
|
|
375
|
+
bgColors = null;
|
|
376
|
+
bgElms.push(bgElm);
|
|
377
|
+
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (bgColor.alpha !== 0) {
|
|
382
|
+
// store elements contributing to the br color.
|
|
383
|
+
bgElms.push(bgElm);
|
|
384
|
+
bgColors.push(bgColor);
|
|
385
|
+
|
|
386
|
+
// Exit if the background is opaque
|
|
387
|
+
return bgColor.alpha === 1;
|
|
388
|
+
} else {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
if (bgColors !== null && elmStack !== null) {
|
|
394
|
+
// Mix the colors together, on top of a default white
|
|
395
|
+
bgColors.push(new color.Color(255, 255, 255, 1));
|
|
396
|
+
var colors = bgColors.reduce(color.flattenColors);
|
|
397
|
+
return colors;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return null;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Determines whether an element has a fully opaque background, whether solid color or an image
|
|
405
|
+
* @param {Element} node
|
|
406
|
+
* @return {Boolean} false if the background is transparent, true otherwise
|
|
407
|
+
*/
|
|
408
|
+
dom.isOpaque = function(node) {
|
|
409
|
+
let style = window.getComputedStyle(node);
|
|
410
|
+
return elmHasImage(node, style) || getBgColor(node, style).alpha === 1;
|
|
411
|
+
};
|