govuk_publishing_components 21.16.3 → 21.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/component_guide/accessibility-test.js +0 -6
- data/app/views/govuk_publishing_components/components/docs/machine_readable_metadata.yml +7 -0
- data/lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb +34 -0
- data/lib/govuk_publishing_components/presenters/schema_org.rb +3 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/CHANGELOG.md +166 -2
- data/node_modules/axe-core/CONTRIBUTING.md +5 -5
- data/node_modules/axe-core/README.md +4 -4
- data/node_modules/axe-core/axe.d.ts +27 -11
- data/node_modules/axe-core/axe.js +9597 -2431
- data/node_modules/axe-core/axe.min.js +2 -2
- data/node_modules/axe-core/bower.json +1 -1
- data/node_modules/axe-core/doc/API.md +211 -128
- data/node_modules/axe-core/doc/accessibility-supported.md +1 -1
- data/node_modules/axe-core/doc/aria-supported.md +4 -13
- data/node_modules/axe-core/doc/backwards-compatibility-doc.md +93 -0
- data/node_modules/axe-core/doc/code-submission-guidelines.md +4 -4
- data/node_modules/axe-core/doc/developer-guide.md +27 -13
- data/node_modules/axe-core/doc/examples/chrome-debugging-protocol/package.json +5 -2
- data/node_modules/axe-core/doc/examples/jasmine/README.md +3 -5
- data/node_modules/axe-core/doc/examples/jasmine/karma.conf.js +29 -0
- data/node_modules/axe-core/doc/examples/jasmine/package.json +6 -5
- data/node_modules/axe-core/doc/examples/jest_react/README.md +1 -1
- data/node_modules/axe-core/doc/examples/jest_react/link.test.js +3 -3
- data/node_modules/axe-core/doc/examples/jest_react/package.json +9 -9
- data/node_modules/axe-core/doc/examples/jsdom/package.json +15 -0
- data/node_modules/axe-core/doc/examples/mocha/README.md +5 -7
- data/node_modules/axe-core/doc/examples/mocha/karma.conf.js +29 -0
- data/node_modules/axe-core/doc/examples/mocha/package.json +7 -6
- data/node_modules/axe-core/doc/examples/phantomjs/README.md +3 -3
- data/node_modules/axe-core/doc/examples/phantomjs/axe-phantom.js +4 -2
- data/node_modules/axe-core/doc/examples/phantomjs/package.json +3 -3
- data/node_modules/axe-core/doc/examples/puppeteer/package.json +5 -2
- data/node_modules/axe-core/doc/examples/qunit/README.md +2 -2
- data/node_modules/axe-core/doc/examples/qunit/package.json +2 -2
- data/node_modules/axe-core/doc/examples/test-examples.js +32 -0
- data/node_modules/axe-core/doc/plugins.md +10 -10
- data/node_modules/axe-core/doc/projects.md +12 -8
- data/node_modules/axe-core/doc/rule-descriptions.md +87 -79
- data/node_modules/axe-core/doc/rule-development.md +30 -2
- data/node_modules/axe-core/lib/checks/aria/allowed-attr.js +1 -1
- data/node_modules/axe-core/lib/checks/aria/aria-roledescription.js +14 -0
- data/node_modules/axe-core/lib/checks/aria/aria-roledescription.json +23 -0
- data/node_modules/axe-core/lib/checks/aria/no-implicit-explicit-label.js +21 -0
- data/node_modules/axe-core/lib/checks/aria/no-implicit-explicit-label.json +11 -0
- data/node_modules/axe-core/lib/checks/aria/required-attr.js +32 -7
- data/node_modules/axe-core/lib/checks/aria/required-children.js +40 -14
- data/node_modules/axe-core/lib/checks/aria/required-children.json +12 -1
- data/node_modules/axe-core/lib/checks/aria/required-parent.js +1 -1
- data/node_modules/axe-core/lib/checks/aria/unsupportedattr.js +1 -1
- data/node_modules/axe-core/lib/checks/aria/valid-attr-value.js +50 -17
- data/node_modules/axe-core/lib/checks/aria/valid-attr-value.json +2 -1
- data/node_modules/axe-core/lib/checks/aria/valid-attr.js +1 -1
- data/node_modules/axe-core/lib/checks/color/color-contrast.js +2 -2
- data/node_modules/axe-core/lib/checks/forms/autocomplete-appropriate.js +4 -4
- data/node_modules/axe-core/lib/checks/forms/autocomplete-valid.js +1 -1
- data/node_modules/axe-core/lib/checks/forms/fieldset.json +1 -0
- data/node_modules/axe-core/lib/checks/forms/group-labelledby.json +1 -0
- data/node_modules/axe-core/lib/checks/keyboard/focusable-content.js +16 -0
- data/node_modules/axe-core/lib/checks/keyboard/focusable-content.json +11 -0
- data/node_modules/axe-core/lib/checks/keyboard/focusable-element.js +12 -0
- data/node_modules/axe-core/lib/checks/keyboard/focusable-element.json +11 -0
- data/node_modules/axe-core/lib/checks/keyboard/tabindex.js +6 -1
- data/node_modules/axe-core/lib/checks/label/alt-space-value.js +3 -2
- data/node_modules/axe-core/lib/checks/label/duplicate-img-label.js +18 -15
- data/node_modules/axe-core/lib/checks/label/label-content-name-mismatch.js +13 -3
- data/node_modules/axe-core/lib/checks/label/label-content-name-mismatch.json +4 -0
- data/node_modules/axe-core/lib/checks/label/multiple-label.js +22 -12
- data/node_modules/axe-core/lib/checks/label/multiple-label.json +1 -1
- data/node_modules/axe-core/lib/checks/landmarks/landmark-is-unique-after.js +23 -0
- data/node_modules/axe-core/lib/checks/landmarks/landmark-is-unique.js +7 -0
- data/node_modules/axe-core/lib/checks/landmarks/landmark-is-unique.json +12 -0
- data/node_modules/axe-core/lib/checks/lists/listitem.js +1 -0
- data/node_modules/axe-core/lib/checks/lists/listitem.json +1 -1
- data/node_modules/axe-core/lib/checks/lists/only-listitems.js +0 -4
- data/node_modules/axe-core/lib/checks/mobile/css-orientation-lock.js +8 -6
- data/node_modules/axe-core/lib/checks/navigation/region.js +2 -19
- data/node_modules/axe-core/lib/checks/shared/avoid-inline-spacing.js +18 -0
- data/node_modules/axe-core/lib/checks/shared/avoid-inline-spacing.json +11 -0
- data/node_modules/axe-core/lib/checks/shared/exists.js +1 -1
- data/node_modules/axe-core/lib/checks/shared/exists.json +1 -1
- data/node_modules/axe-core/lib/checks/shared/has-alt.js +6 -4
- data/node_modules/axe-core/lib/checks/shared/non-empty-alt.js +1 -1
- data/node_modules/axe-core/lib/checks/tables/caption-faked.json +1 -1
- data/node_modules/axe-core/lib/checks/tables/td-has-header.js +5 -4
- data/node_modules/axe-core/lib/checks/tables/th-has-data-cells.js +19 -29
- data/node_modules/axe-core/lib/commons/aria/get-owned-virtual.js +1 -1
- data/node_modules/axe-core/lib/commons/aria/index.js +50 -46
- data/node_modules/axe-core/lib/commons/aria/is-accessible-ref.js +41 -37
- data/node_modules/axe-core/lib/commons/aria/label-virtual.js +2 -2
- data/node_modules/axe-core/lib/commons/aria/roles.js +1 -1
- data/node_modules/axe-core/lib/commons/aria/validate-attr-value.js +0 -1
- data/node_modules/axe-core/lib/commons/color/center-point-of-rect.js +30 -0
- data/node_modules/axe-core/lib/commons/color/contrast.js +7 -1
- data/node_modules/axe-core/lib/commons/color/element-has-image.js +36 -0
- data/node_modules/axe-core/lib/commons/color/get-background-color.js +332 -306
- data/node_modules/axe-core/lib/commons/color/get-foreground-color.js +35 -6
- data/node_modules/axe-core/lib/commons/color/get-own-background-color.js +22 -0
- data/node_modules/axe-core/lib/commons/dom/find-up.js +5 -5
- data/node_modules/axe-core/lib/commons/dom/get-scroll-offset.js +0 -1
- data/node_modules/axe-core/lib/commons/dom/get-tabbable-elements.js +1 -1
- data/node_modules/axe-core/lib/commons/dom/has-content-virtual.js +7 -5
- data/node_modules/axe-core/lib/commons/dom/is-focusable.js +8 -5
- data/node_modules/axe-core/lib/commons/dom/is-hidden-with-css.js +15 -2
- data/node_modules/axe-core/lib/commons/dom/is-in-text-block.js +1 -2
- data/node_modules/axe-core/lib/commons/dom/is-skip-link.js +45 -0
- data/node_modules/axe-core/lib/commons/dom/is-visible.js +43 -17
- data/node_modules/axe-core/lib/commons/dom/is-visual-content.js +0 -1
- data/node_modules/axe-core/lib/commons/dom/visually-contains.js +0 -1
- data/node_modules/axe-core/lib/commons/dom/visually-overlaps.js +0 -1
- data/node_modules/axe-core/lib/commons/forms/index.js +8 -0
- data/node_modules/axe-core/lib/commons/forms/is-aria-combobox.js +13 -0
- data/node_modules/axe-core/lib/commons/forms/is-aria-listbox.js +13 -0
- data/node_modules/axe-core/lib/commons/forms/is-aria-range.js +14 -0
- data/node_modules/axe-core/lib/commons/forms/is-aria-textbox.js +13 -0
- data/node_modules/axe-core/lib/commons/forms/is-native-select.js +13 -0
- data/node_modules/axe-core/lib/commons/forms/is-native-textbox.js +28 -0
- data/node_modules/axe-core/lib/commons/table/get-cell-position.js +2 -2
- data/node_modules/axe-core/lib/commons/table/get-headers.js +55 -11
- data/node_modules/axe-core/lib/commons/table/get-scope.js +1 -1
- data/node_modules/axe-core/lib/commons/table/is-data-table.js +0 -1
- data/node_modules/axe-core/lib/commons/table/to-grid.js +2 -2
- data/node_modules/axe-core/lib/commons/text/accessible-text-virtual.js +5 -5
- data/node_modules/axe-core/lib/commons/text/form-control-value.js +18 -30
- data/node_modules/axe-core/lib/commons/text/is-icon-ligature.js +210 -0
- data/node_modules/axe-core/lib/commons/text/is-valid-autocomplete.js +0 -1
- data/node_modules/axe-core/lib/commons/text/label-text.js +1 -1
- data/node_modules/axe-core/lib/commons/text/label-virtual.js +1 -1
- data/node_modules/axe-core/lib/commons/text/native-text-methods.js +1 -1
- data/node_modules/axe-core/lib/commons/text/subtree-text.js +3 -3
- data/node_modules/axe-core/lib/commons/text/unicode.js +15 -0
- data/node_modules/axe-core/lib/commons/text/visible-text-nodes.js +25 -0
- data/node_modules/axe-core/lib/commons/text/visible-virtual.js +1 -1
- data/node_modules/axe-core/lib/core/base/audit.js +90 -15
- data/node_modules/axe-core/lib/core/base/cache.js +33 -0
- data/node_modules/axe-core/lib/core/base/check.js +48 -1
- data/node_modules/axe-core/lib/core/base/context.js +15 -14
- data/node_modules/axe-core/lib/core/base/rule.js +223 -46
- data/node_modules/axe-core/lib/core/base/virtual-node/abstract-virtual-node.js +40 -0
- data/node_modules/axe-core/lib/core/base/virtual-node/serial-virtual-node.js +86 -0
- data/node_modules/axe-core/lib/core/base/virtual-node/virtual-node.js +85 -0
- data/node_modules/axe-core/lib/core/constants.js +10 -2
- data/node_modules/axe-core/lib/core/imports/index.js +28 -3
- data/node_modules/axe-core/lib/core/index.js +2 -4
- data/node_modules/axe-core/lib/core/public/configure.js +28 -1
- data/node_modules/axe-core/lib/core/public/run-rules.js +2 -0
- data/node_modules/axe-core/lib/core/public/run-virtual-rule.js +50 -0
- data/node_modules/axe-core/lib/core/public/run.js +13 -2
- data/node_modules/axe-core/lib/core/reporters/helpers/process-aggregate.js +1 -1
- data/node_modules/axe-core/lib/core/reporters/na.js +4 -0
- data/node_modules/axe-core/lib/core/reporters/raw-env.js +12 -0
- data/node_modules/axe-core/lib/core/reporters/raw.js +25 -1
- data/node_modules/axe-core/lib/core/utils/are-styles-set.js +4 -7
- data/node_modules/axe-core/lib/core/utils/assert.js +12 -0
- data/node_modules/axe-core/lib/core/utils/collect-results-from-frames.js +2 -2
- data/node_modules/axe-core/lib/core/utils/contains.js +27 -13
- data/node_modules/axe-core/lib/core/utils/css-parser.js +2 -0
- data/node_modules/axe-core/lib/core/utils/element-matches.js +5 -1
- data/node_modules/axe-core/lib/core/utils/escape-selector.js +1 -2
- data/node_modules/axe-core/lib/core/utils/flattened-tree.js +47 -61
- data/node_modules/axe-core/lib/core/utils/get-check-option.js +0 -1
- data/node_modules/axe-core/lib/core/utils/get-friendly-uri-end.js +1 -1
- data/node_modules/axe-core/lib/core/utils/get-node-attributes.js +21 -0
- data/node_modules/axe-core/lib/core/utils/get-scroll.js +39 -0
- data/node_modules/axe-core/lib/core/utils/get-selector.js +9 -6
- data/node_modules/axe-core/lib/core/utils/get-stylesheet-factory.js +51 -0
- data/node_modules/axe-core/lib/core/utils/get-xpath.js +0 -1
- data/node_modules/axe-core/lib/core/utils/is-hidden.js +16 -4
- data/node_modules/axe-core/lib/core/utils/is-html-element.js +5 -5
- data/node_modules/axe-core/lib/core/utils/is-shadow-root.js +3 -3
- data/node_modules/axe-core/lib/core/utils/memoize.js +17 -0
- data/node_modules/axe-core/lib/core/utils/parse-crossorigin-stylesheet.js +53 -0
- data/node_modules/axe-core/lib/core/utils/parse-sameorigin-stylesheet.js +96 -0
- data/node_modules/axe-core/lib/core/utils/parse-stylesheet.js +70 -0
- data/node_modules/axe-core/lib/core/utils/performance-timer.js +7 -2
- data/node_modules/axe-core/lib/core/utils/preload-cssom.js +77 -281
- data/node_modules/axe-core/lib/core/utils/preload.js +49 -23
- data/node_modules/axe-core/lib/core/utils/qsa.js +39 -50
- data/node_modules/axe-core/lib/core/utils/respondable.js +20 -3
- data/node_modules/axe-core/lib/core/utils/rule-should-run.js +0 -1
- data/node_modules/axe-core/lib/core/utils/scroll-state.js +12 -25
- data/node_modules/axe-core/lib/core/utils/select.js +12 -23
- data/node_modules/axe-core/lib/core/utils/uuid.js +1 -2
- data/node_modules/axe-core/lib/intro.stub +1 -1
- data/node_modules/axe-core/lib/misc/incomplete-fallback.json +1 -1
- data/node_modules/axe-core/lib/rules/aria-allowed-attr-matches.js +1 -1
- data/node_modules/axe-core/lib/rules/aria-form-field-name-matches.js +50 -0
- data/node_modules/axe-core/lib/rules/aria-has-attr-matches.js +1 -1
- data/node_modules/axe-core/lib/rules/aria-hidden-focus.json +1 -1
- data/node_modules/axe-core/lib/rules/aria-input-field-name.json +13 -0
- data/node_modules/axe-core/lib/rules/aria-roledescription.json +12 -0
- data/node_modules/axe-core/lib/rules/aria-toggle-field-name.json +18 -0
- data/node_modules/axe-core/lib/rules/autocomplete-matches.js +14 -10
- data/node_modules/axe-core/lib/rules/avoid-inline-spacing.json +12 -0
- data/node_modules/axe-core/lib/rules/button-name.json +3 -5
- data/node_modules/axe-core/lib/rules/checkboxgroup.json +2 -1
- data/node_modules/axe-core/lib/rules/color-contrast-matches.js +37 -22
- data/node_modules/axe-core/lib/rules/duplicate-id-active-matches.js +1 -1
- data/node_modules/axe-core/lib/rules/duplicate-id-misc-matches.js +2 -2
- data/node_modules/axe-core/lib/rules/form-field-multiple-labels.json +1 -1
- data/node_modules/axe-core/lib/rules/html-has-lang.json +1 -0
- data/node_modules/axe-core/lib/rules/image-alt.json +1 -1
- data/node_modules/axe-core/lib/rules/img-redundant-alt.json +3 -3
- data/node_modules/axe-core/lib/rules/input-button-name.json +26 -0
- data/node_modules/axe-core/lib/rules/landmark-unique-matches.js +41 -0
- data/node_modules/axe-core/lib/rules/landmark-unique.json +13 -0
- data/node_modules/axe-core/lib/rules/link-name.json +5 -4
- data/node_modules/axe-core/lib/rules/meta-refresh.json +8 -1
- data/node_modules/axe-core/lib/rules/radiogroup.json +2 -1
- data/node_modules/axe-core/lib/rules/role-img-alt.json +18 -0
- data/node_modules/axe-core/lib/rules/scrollable-region-focusable-matches.js +30 -0
- data/node_modules/axe-core/lib/rules/scrollable-region-focusable.json +12 -0
- data/node_modules/axe-core/lib/rules/skip-link-matches.js +1 -1
- data/node_modules/axe-core/lib/rules/skip-link.json +1 -1
- data/node_modules/axe-core/lib/rules/video-description.json +3 -1
- data/node_modules/axe-core/locales/de.json +1 -5
- data/node_modules/axe-core/locales/es.json +773 -0
- data/node_modules/axe-core/locales/fr.json +15 -19
- data/node_modules/axe-core/locales/ja.json +65 -11
- data/node_modules/axe-core/locales/ko.json +777 -0
- data/node_modules/axe-core/locales/nl.json +35 -35
- data/node_modules/axe-core/locales/pt_BR.json +773 -0
- data/node_modules/axe-core/package.json +56 -52
- data/node_modules/axe-core/sri-history.json +20 -0
- data/node_modules/axe-core/typings/axe-core/axe-core-tests.ts +5 -15
- data/node_modules/govuk-frontend/package.json +10 -10
- metadata +62 -4
- data/node_modules/axe-core/doc/axelogo2018.png +0 -0
- data/node_modules/axe-core/lib/rules/role-not-button-matches.js +0 -1
|
@@ -26,13 +26,13 @@ axe.utils.shouldPreload = function shouldPreload(options) {
|
|
|
26
26
|
/**
|
|
27
27
|
* Constructs a configuration object representing the preload requested assets & timeout
|
|
28
28
|
* @param {Object} options run configuration options (or defaults) passed via axe.run
|
|
29
|
-
* @return {Object}
|
|
29
|
+
* @return {Object} configuration
|
|
30
30
|
*/
|
|
31
31
|
axe.utils.getPreloadConfig = function getPreloadConfig(options) {
|
|
32
|
-
|
|
32
|
+
const { assets, timeout } = axe.constants.preload;
|
|
33
33
|
const config = {
|
|
34
|
-
assets
|
|
35
|
-
timeout
|
|
34
|
+
assets,
|
|
35
|
+
timeout
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
// if no `preload` is configured via `options` - return default config
|
|
@@ -47,13 +47,13 @@ axe.utils.getPreloadConfig = function getPreloadConfig(options) {
|
|
|
47
47
|
|
|
48
48
|
// check if requested assets to preload are valid items
|
|
49
49
|
const areRequestedAssetsValid = options.preload.assets.every(a =>
|
|
50
|
-
|
|
50
|
+
assets.includes(a.toLowerCase())
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
if (!areRequestedAssetsValid) {
|
|
54
54
|
throw new Error(
|
|
55
55
|
`Requested assets, not supported. ` +
|
|
56
|
-
`Supported assets are: ${
|
|
56
|
+
`Supported assets are: ${assets.join(', ')}.`
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -74,36 +74,62 @@ axe.utils.getPreloadConfig = function getPreloadConfig(options) {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Returns a
|
|
78
|
-
*
|
|
77
|
+
* Returns a Promise with results of all requested preload(able) assets. eg: ['cssom'].
|
|
78
|
+
*
|
|
79
79
|
* @param {Object} options run configuration options (or defaults) passed via axe.run
|
|
80
|
-
* @return {Object}
|
|
80
|
+
* @return {Object} Promise
|
|
81
81
|
*/
|
|
82
82
|
axe.utils.preload = function preload(options) {
|
|
83
83
|
const preloadFunctionsMap = {
|
|
84
84
|
cssom: axe.utils.preloadCssom
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
const q = axe.utils.queue();
|
|
88
|
-
|
|
89
87
|
const shouldPreload = axe.utils.shouldPreload(options);
|
|
90
88
|
if (!shouldPreload) {
|
|
91
|
-
return
|
|
89
|
+
return Promise.resolve();
|
|
92
90
|
}
|
|
93
91
|
|
|
94
|
-
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
const { assets, timeout } = axe.utils.getPreloadConfig(options);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Start `timeout` timer for preloading assets
|
|
97
|
+
* -> reject if allowed time expires.
|
|
98
|
+
*/
|
|
99
|
+
setTimeout(() => reject(`Preload assets timed out.`), timeout);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Fetch requested `assets`
|
|
103
|
+
*/
|
|
95
104
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
105
|
+
Promise.all(
|
|
106
|
+
assets.map(asset =>
|
|
107
|
+
preloadFunctionsMap[asset](options).then(results => {
|
|
108
|
+
return {
|
|
109
|
+
[asset]: results
|
|
110
|
+
};
|
|
103
111
|
})
|
|
104
|
-
|
|
112
|
+
)
|
|
113
|
+
).then(results => {
|
|
114
|
+
/**
|
|
115
|
+
* Combine array of results into an object map
|
|
116
|
+
*
|
|
117
|
+
* From ->
|
|
118
|
+
* [{cssom: [...], aom: [...]}]
|
|
119
|
+
* To ->
|
|
120
|
+
* {
|
|
121
|
+
* cssom: [...]
|
|
122
|
+
* aom: [...]
|
|
123
|
+
* }
|
|
124
|
+
*/
|
|
125
|
+
const preloadAssets = results.reduce((out, result) => {
|
|
126
|
+
return {
|
|
127
|
+
...out,
|
|
128
|
+
...result
|
|
129
|
+
};
|
|
130
|
+
}, {});
|
|
131
|
+
|
|
132
|
+
resolve(preloadAssets);
|
|
105
133
|
});
|
|
106
134
|
});
|
|
107
|
-
|
|
108
|
-
return q;
|
|
109
135
|
};
|
|
@@ -4,50 +4,42 @@ var matchExpressions = function() {};
|
|
|
4
4
|
|
|
5
5
|
// todo: implement an option to follow aria-owns
|
|
6
6
|
|
|
7
|
-
function matchesTag(
|
|
7
|
+
function matchesTag(vNode, exp) {
|
|
8
8
|
return (
|
|
9
|
-
|
|
10
|
-
(exp.tag === '*' ||
|
|
9
|
+
vNode.props.nodeType === 1 &&
|
|
10
|
+
(exp.tag === '*' || vNode.props.nodeName === exp.tag)
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function matchesClasses(
|
|
15
|
-
return (
|
|
16
|
-
!exp.classes ||
|
|
17
|
-
exp.classes.reduce((result, cl) => {
|
|
18
|
-
return result && (node.className && node.className.match(cl.regexp));
|
|
19
|
-
}, true)
|
|
20
|
-
);
|
|
14
|
+
function matchesClasses(vNode, exp) {
|
|
15
|
+
return !exp.classes || exp.classes.every(cl => vNode.hasClass(cl.value));
|
|
21
16
|
}
|
|
22
17
|
|
|
23
|
-
function matchesAttributes(
|
|
18
|
+
function matchesAttributes(vNode, exp) {
|
|
24
19
|
return (
|
|
25
20
|
!exp.attributes ||
|
|
26
|
-
exp.attributes.
|
|
27
|
-
var nodeAtt =
|
|
28
|
-
return
|
|
29
|
-
}
|
|
21
|
+
exp.attributes.every(att => {
|
|
22
|
+
var nodeAtt = vNode.attr(att.key);
|
|
23
|
+
return nodeAtt !== null && (!att.value || att.test(nodeAtt));
|
|
24
|
+
})
|
|
30
25
|
);
|
|
31
26
|
}
|
|
32
27
|
|
|
33
|
-
function matchesId(
|
|
34
|
-
return !exp.id ||
|
|
28
|
+
function matchesId(vNode, exp) {
|
|
29
|
+
return !exp.id || vNode.props.id === exp.id;
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
function matchesPseudos(target, exp) {
|
|
38
33
|
if (
|
|
39
34
|
!exp.pseudos ||
|
|
40
|
-
exp.pseudos.
|
|
35
|
+
exp.pseudos.every(pseudo => {
|
|
41
36
|
if (pseudo.name === 'not') {
|
|
42
|
-
return (
|
|
43
|
-
result &&
|
|
44
|
-
!matchExpressions([target], pseudo.expressions, false).length
|
|
45
|
-
);
|
|
37
|
+
return !matchExpressions([target], pseudo.expressions, false).length;
|
|
46
38
|
}
|
|
47
39
|
throw new Error(
|
|
48
40
|
'the pseudo selector ' + pseudo.name + ' has not yet been implemented'
|
|
49
41
|
);
|
|
50
|
-
}
|
|
42
|
+
})
|
|
51
43
|
) {
|
|
52
44
|
return true;
|
|
53
45
|
}
|
|
@@ -66,13 +58,11 @@ var escapeRegExp = (function() {
|
|
|
66
58
|
var reUnescape = /\\/g;
|
|
67
59
|
|
|
68
60
|
function convertAttributes(atts) {
|
|
69
|
-
/*eslint indent:0*/
|
|
70
61
|
/*! Credit Mootools Copyright Mootools, MIT License */
|
|
71
62
|
if (!atts) {
|
|
72
63
|
return;
|
|
73
64
|
}
|
|
74
65
|
return atts.map(att => {
|
|
75
|
-
// eslint complexity:["error", 13]
|
|
76
66
|
var attributeKey = att.name.replace(reUnescape, '');
|
|
77
67
|
var attributeValue = (att.value || '').replace(reUnescape, '');
|
|
78
68
|
var test, regexp;
|
|
@@ -154,7 +144,7 @@ function convertPseudos(pseudos) {
|
|
|
154
144
|
var expressions;
|
|
155
145
|
|
|
156
146
|
if (p.name === 'not') {
|
|
157
|
-
expressions =
|
|
147
|
+
expressions = p.value;
|
|
158
148
|
expressions = expressions.selectors
|
|
159
149
|
? expressions.selectors
|
|
160
150
|
: [expressions];
|
|
@@ -196,41 +186,40 @@ convertExpressions = function(expressions) {
|
|
|
196
186
|
});
|
|
197
187
|
};
|
|
198
188
|
|
|
199
|
-
function createLocalVariables(
|
|
189
|
+
function createLocalVariables(vNodes, anyLevel, thisLevel, parentShadowId) {
|
|
200
190
|
let retVal = {
|
|
201
|
-
|
|
191
|
+
vNodes: vNodes.slice(),
|
|
202
192
|
anyLevel: anyLevel,
|
|
203
193
|
thisLevel: thisLevel,
|
|
204
194
|
parentShadowId: parentShadowId
|
|
205
195
|
};
|
|
206
|
-
retVal.
|
|
196
|
+
retVal.vNodes.reverse();
|
|
207
197
|
return retVal;
|
|
208
198
|
}
|
|
209
199
|
|
|
210
|
-
function matchesSelector(
|
|
200
|
+
function matchesSelector(vNode, exp) {
|
|
211
201
|
return (
|
|
212
|
-
matchesTag(
|
|
213
|
-
matchesClasses(
|
|
214
|
-
matchesAttributes(
|
|
215
|
-
matchesId(
|
|
216
|
-
matchesPseudos(
|
|
202
|
+
matchesTag(vNode, exp[0]) &&
|
|
203
|
+
matchesClasses(vNode, exp[0]) &&
|
|
204
|
+
matchesAttributes(vNode, exp[0]) &&
|
|
205
|
+
matchesId(vNode, exp[0]) &&
|
|
206
|
+
matchesPseudos(vNode, exp[0])
|
|
217
207
|
);
|
|
218
208
|
}
|
|
219
209
|
|
|
220
210
|
matchExpressions = function(domTree, expressions, recurse, filter) {
|
|
221
|
-
/*eslint max-statements:["error", 34], complexity:["error", 22]*/
|
|
222
211
|
let stack = [];
|
|
223
|
-
let
|
|
212
|
+
let vNodes = Array.isArray(domTree) ? domTree : [domTree];
|
|
224
213
|
let currentLevel = createLocalVariables(
|
|
225
|
-
|
|
214
|
+
vNodes,
|
|
226
215
|
expressions,
|
|
227
216
|
[],
|
|
228
217
|
domTree[0].shadowId
|
|
229
218
|
);
|
|
230
219
|
let result = [];
|
|
231
220
|
|
|
232
|
-
while (currentLevel.
|
|
233
|
-
let
|
|
221
|
+
while (currentLevel.vNodes.length) {
|
|
222
|
+
let vNode = currentLevel.vNodes.pop();
|
|
234
223
|
let childOnly = []; // we will add hierarchical '>' selectors here
|
|
235
224
|
let childAny = [];
|
|
236
225
|
let combined = currentLevel.anyLevel.slice().concat(currentLevel.thisLevel);
|
|
@@ -239,12 +228,12 @@ matchExpressions = function(domTree, expressions, recurse, filter) {
|
|
|
239
228
|
for (let i = 0; i < combined.length; i++) {
|
|
240
229
|
let exp = combined[i];
|
|
241
230
|
if (
|
|
242
|
-
|
|
243
|
-
(
|
|
231
|
+
(!exp[0].id || vNode.shadowId === currentLevel.parentShadowId) &&
|
|
232
|
+
matchesSelector(vNode, exp)
|
|
244
233
|
) {
|
|
245
234
|
if (exp.length === 1) {
|
|
246
|
-
if (!added && (!filter || filter(
|
|
247
|
-
result.push(
|
|
235
|
+
if (!added && (!filter || filter(vNode))) {
|
|
236
|
+
result.push(vNode);
|
|
248
237
|
added = true;
|
|
249
238
|
}
|
|
250
239
|
} else {
|
|
@@ -265,24 +254,24 @@ matchExpressions = function(domTree, expressions, recurse, filter) {
|
|
|
265
254
|
}
|
|
266
255
|
}
|
|
267
256
|
if (
|
|
268
|
-
currentLevel.
|
|
269
|
-
(
|
|
257
|
+
(!exp[0].id || vNode.shadowId === currentLevel.parentShadowId) &&
|
|
258
|
+
currentLevel.anyLevel.includes(exp)
|
|
270
259
|
) {
|
|
271
260
|
childAny.push(exp);
|
|
272
261
|
}
|
|
273
262
|
}
|
|
274
263
|
// "recurse"
|
|
275
|
-
if (
|
|
264
|
+
if (vNode.children && vNode.children.length && recurse) {
|
|
276
265
|
stack.push(currentLevel);
|
|
277
266
|
currentLevel = createLocalVariables(
|
|
278
|
-
|
|
267
|
+
vNode.children,
|
|
279
268
|
childAny,
|
|
280
269
|
childOnly,
|
|
281
|
-
|
|
270
|
+
vNode.shadowId
|
|
282
271
|
);
|
|
283
272
|
}
|
|
284
273
|
// check for "return"
|
|
285
|
-
while (!currentLevel.
|
|
274
|
+
while (!currentLevel.vNodes.length && stack.length) {
|
|
286
275
|
currentLevel = stack.pop();
|
|
287
276
|
}
|
|
288
277
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
]);
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* get the unique string to be used to identify our instance of
|
|
16
|
+
* get the unique string to be used to identify our instance of axe
|
|
17
17
|
* @private
|
|
18
18
|
*/
|
|
19
19
|
function _getSource() {
|
|
@@ -86,6 +86,12 @@
|
|
|
86
86
|
_keepalive: keepalive
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
var axeRespondables = axe._cache.get('axeRespondables');
|
|
90
|
+
if (!axeRespondables) {
|
|
91
|
+
axeRespondables = {};
|
|
92
|
+
axe._cache.set('axeRespondables', axeRespondables);
|
|
93
|
+
}
|
|
94
|
+
axeRespondables[uuid] = true;
|
|
89
95
|
if (typeof callback === 'function') {
|
|
90
96
|
messages[uuid] = callback;
|
|
91
97
|
}
|
|
@@ -206,7 +212,6 @@
|
|
|
206
212
|
window.addEventListener(
|
|
207
213
|
'message',
|
|
208
214
|
function(e) {
|
|
209
|
-
/* eslint max-statements: ["error", 20]*/
|
|
210
215
|
var data = parseMessage(e.data);
|
|
211
216
|
if (!data) {
|
|
212
217
|
return;
|
|
@@ -214,6 +219,18 @@
|
|
|
214
219
|
|
|
215
220
|
var uuid = data.uuid;
|
|
216
221
|
|
|
222
|
+
/**
|
|
223
|
+
* NOTE: messages from other contexts (frames) in response
|
|
224
|
+
* to a message should not contain a topic. We ignore these
|
|
225
|
+
* messages to prevent rogue postMessage handlers reflecting
|
|
226
|
+
* our messages.
|
|
227
|
+
* @see https://github.com/dequelabs/axe-core/issues/1754
|
|
228
|
+
*/
|
|
229
|
+
var axeRespondables = axe._cache.get('axeRespondables') || {};
|
|
230
|
+
if (axeRespondables[uuid] && data.topic && e.source !== window) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
217
234
|
var keepalive = data._keepalive;
|
|
218
235
|
var callback = messages[uuid];
|
|
219
236
|
|
|
@@ -231,7 +248,7 @@
|
|
|
231
248
|
try {
|
|
232
249
|
publish(e.source, data, keepalive);
|
|
233
250
|
} catch (err) {
|
|
234
|
-
post(e.source,
|
|
251
|
+
post(e.source, null, err, uuid, false);
|
|
235
252
|
}
|
|
236
253
|
}
|
|
237
254
|
},
|
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Return the scroll position of scrollable elements
|
|
3
|
-
*/
|
|
4
|
-
function getScroll(elm) {
|
|
5
|
-
const style = window.getComputedStyle(elm);
|
|
6
|
-
const visibleOverflowY = style.getPropertyValue('overflow-y') === 'visible';
|
|
7
|
-
const visibleOverflowX = style.getPropertyValue('overflow-x') === 'visible';
|
|
8
|
-
|
|
9
|
-
if (
|
|
10
|
-
// See if the element hides overflowing content
|
|
11
|
-
(!visibleOverflowY && elm.scrollHeight > elm.clientHeight) ||
|
|
12
|
-
(!visibleOverflowX && elm.scrollWidth > elm.clientWidth)
|
|
13
|
-
) {
|
|
14
|
-
return { elm, top: elm.scrollTop, left: elm.scrollLeft };
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
1
|
/**
|
|
19
2
|
* set the scroll position of an element
|
|
20
3
|
*/
|
|
21
4
|
function setScroll(elm, top, left) {
|
|
22
5
|
if (elm === window) {
|
|
23
|
-
return elm.scroll(
|
|
6
|
+
return elm.scroll(left, top);
|
|
24
7
|
} else {
|
|
25
8
|
elm.scrollTop = top;
|
|
26
9
|
elm.scrollLeft = left;
|
|
@@ -31,13 +14,17 @@ function setScroll(elm, top, left) {
|
|
|
31
14
|
* Create an array scroll positions from descending elements
|
|
32
15
|
*/
|
|
33
16
|
function getElmScrollRecursive(root) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
17
|
+
// Need to also get .childNodes since SVGs in IE don't have .children.
|
|
18
|
+
return Array.from(root.children || root.childNodes || []).reduce(
|
|
19
|
+
(scrolls, elm) => {
|
|
20
|
+
const scroll = axe.utils.getScroll(elm);
|
|
21
|
+
if (scroll) {
|
|
22
|
+
scrolls.push(scroll);
|
|
23
|
+
}
|
|
24
|
+
return scrolls.concat(getElmScrollRecursive(elm));
|
|
25
|
+
},
|
|
26
|
+
[]
|
|
27
|
+
);
|
|
41
28
|
}
|
|
42
29
|
|
|
43
30
|
/**
|
|
@@ -25,14 +25,14 @@ function getDeepest(collection) {
|
|
|
25
25
|
function isNodeInContext(node, context) {
|
|
26
26
|
'use strict';
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
const include =
|
|
29
29
|
context.include &&
|
|
30
30
|
getDeepest(
|
|
31
31
|
context.include.filter(function(candidate) {
|
|
32
32
|
return axe.utils.contains(candidate, node);
|
|
33
33
|
})
|
|
34
34
|
);
|
|
35
|
-
|
|
35
|
+
const exclude =
|
|
36
36
|
context.exclude &&
|
|
37
37
|
getDeepest(
|
|
38
38
|
context.exclude.filter(function(candidate) {
|
|
@@ -58,7 +58,7 @@ function isNodeInContext(node, context) {
|
|
|
58
58
|
function pushNode(result, nodes) {
|
|
59
59
|
'use strict';
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
let temp;
|
|
62
62
|
|
|
63
63
|
if (result.length === 0) {
|
|
64
64
|
return nodes;
|
|
@@ -69,7 +69,7 @@ function pushNode(result, nodes) {
|
|
|
69
69
|
result = nodes;
|
|
70
70
|
nodes = temp;
|
|
71
71
|
}
|
|
72
|
-
for (
|
|
72
|
+
for (let i = 0, l = nodes.length; i < l; i++) {
|
|
73
73
|
if (!result.includes(nodes[i])) {
|
|
74
74
|
result.push(nodes[i]);
|
|
75
75
|
}
|
|
@@ -84,10 +84,7 @@ function pushNode(result, nodes) {
|
|
|
84
84
|
*/
|
|
85
85
|
function reduceIncludes(includes) {
|
|
86
86
|
return includes.reduce((res, el) => {
|
|
87
|
-
if (
|
|
88
|
-
!res.length ||
|
|
89
|
-
!res[res.length - 1].actualNode.contains(el.actualNode)
|
|
90
|
-
) {
|
|
87
|
+
if (!res.length || !axe.utils.contains(res[res.length - 1], el)) {
|
|
91
88
|
res.push(el);
|
|
92
89
|
}
|
|
93
90
|
return res;
|
|
@@ -100,37 +97,29 @@ function reduceIncludes(includes) {
|
|
|
100
97
|
* @param {Context} context The "resolved" context object, @see Context
|
|
101
98
|
* @return {Array} Matching virtual DOM nodes sorted by DOM order
|
|
102
99
|
*/
|
|
103
|
-
/*eslint max-statements:["error", 20]*/
|
|
104
100
|
axe.utils.select = function select(selector, context) {
|
|
105
101
|
'use strict';
|
|
106
102
|
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
let result = [];
|
|
104
|
+
let candidate;
|
|
109
105
|
if (axe._selectCache) {
|
|
110
106
|
// if used outside of run, it will still work
|
|
111
|
-
for (
|
|
107
|
+
for (let j = 0, l = axe._selectCache.length; j < l; j++) {
|
|
112
108
|
// First see whether the item exists in the cache
|
|
113
|
-
|
|
109
|
+
const item = axe._selectCache[j];
|
|
114
110
|
if (item.selector === selector) {
|
|
115
111
|
return item.result;
|
|
116
112
|
}
|
|
117
113
|
}
|
|
118
114
|
}
|
|
119
|
-
|
|
115
|
+
const curried = (function(context) {
|
|
120
116
|
return function(node) {
|
|
121
117
|
return isNodeInContext(node, context);
|
|
122
118
|
};
|
|
123
119
|
})(context);
|
|
124
|
-
|
|
125
|
-
for (
|
|
120
|
+
const reducedIncludes = reduceIncludes(context.include);
|
|
121
|
+
for (let i = 0; i < reducedIncludes.length; i++) {
|
|
126
122
|
candidate = reducedIncludes[i];
|
|
127
|
-
if (
|
|
128
|
-
candidate.actualNode.nodeType === candidate.actualNode.ELEMENT_NODE &&
|
|
129
|
-
axe.utils.matchesSelector(candidate.actualNode, selector) &&
|
|
130
|
-
curried(candidate)
|
|
131
|
-
) {
|
|
132
|
-
result = pushNode(result, [candidate]);
|
|
133
|
-
}
|
|
134
123
|
result = pushNode(
|
|
135
124
|
result,
|
|
136
125
|
axe.utils.querySelectorAllFilter(candidate, selector, curried)
|