govuk_publishing_components 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/accessibility-test.js +40 -30
- data/app/controllers/govuk_publishing_components/application_controller.rb +15 -0
- data/app/models/govuk_publishing_components/shared_accessibility_criteria.rb +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c89ac97d233cfea87960f74561b440b7b512f4f5
|
4
|
+
data.tar.gz: 8eead0093c99748abd32686edd8e7f664f8485d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 605d6cab7fa68c8257bad9e133f95ce3e4050a3bf66729bfe60caa281947b876a5a9a79cb0bd96d792075c7746ab8fb2a8b5feb7343f5c145f488e6f6fcb55e8
|
7
|
+
data.tar.gz: 3c563b212ffa0a53cda59aba21e4873e1a2c18476b98ab103237ebc150844272749786bbc71b8a1e0d1f0aee248d026e15279529fb38524c1fa1babc5f569bfb
|
@@ -7,7 +7,7 @@
|
|
7
7
|
}
|
8
8
|
|
9
9
|
if (!document.querySelector(selector)) {
|
10
|
-
return callback(
|
10
|
+
return callback()
|
11
11
|
}
|
12
12
|
|
13
13
|
var axeOptions = {
|
@@ -15,20 +15,27 @@
|
|
15
15
|
include: [selector]
|
16
16
|
}
|
17
17
|
|
18
|
+
// TODO: Remove when aXe core patched
|
19
|
+
// https://github.com/dequelabs/axe-core/issues/525
|
20
|
+
if (document.querySelector('svg') && !(document.querySelector('svg').children instanceof HTMLCollection)) {
|
21
|
+
delete axeOptions['restoreScroll']
|
22
|
+
}
|
23
|
+
|
18
24
|
axe.run(selector, axeOptions, function (err, results) {
|
19
25
|
if (err) {
|
20
|
-
callback('aXe Error: ' + err)
|
26
|
+
return callback('aXe Error: ' + err)
|
21
27
|
}
|
22
28
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
if (violations.length === 0 && incompleteWarnings.length === 0) {
|
27
|
-
return callback('No accessibility issues found')
|
29
|
+
if (typeof results === "undefined") {
|
30
|
+
return callback('aXe Error: Expected results but none returned')
|
28
31
|
}
|
29
32
|
|
30
|
-
var
|
31
|
-
var
|
33
|
+
var errorText = _processViolations(results.violations, results.url)
|
34
|
+
var incompleteWarningsObj = _processIncompleteWarnings(results.incomplete)
|
35
|
+
|
36
|
+
var bodyClass = results.violations.length === 0 ? "js-test-a11y-success" : "js-test-a11y-failed"
|
37
|
+
document.body.classList.add(bodyClass);
|
38
|
+
document.body.classList.add("js-test-a11y-finished");
|
32
39
|
|
33
40
|
callback(undefined, errorText, incompleteWarningsObj)
|
34
41
|
})
|
@@ -51,33 +58,36 @@
|
|
51
58
|
].join('\n\n\n')
|
52
59
|
}).join('\n\n- - -\n\n')
|
53
60
|
)
|
54
|
-
}
|
55
|
-
|
56
|
-
console.info("aXe: No accessibility errors found")
|
61
|
+
} else {
|
62
|
+
return false
|
57
63
|
}
|
58
64
|
}
|
59
65
|
|
60
66
|
var _processIncompleteWarnings = function(incompleteWarnings) {
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
67
|
+
if (incompleteWarnings.length !== 0) {
|
68
|
+
return (
|
69
|
+
incompleteWarnings.map(function (incomplete) {
|
70
|
+
var help = incomplete.help
|
71
|
+
var helpUrl = _formatHelpUrl(incomplete.helpUrl)
|
72
|
+
var cssSelector = incomplete.nodes.map(function (node) {
|
73
|
+
return {
|
74
|
+
'selector': node.target,
|
75
|
+
'reason': node.any.map(function(item) {
|
76
|
+
return item.message
|
77
|
+
})
|
78
|
+
}
|
79
|
+
})
|
80
|
+
|
66
81
|
return {
|
67
|
-
'
|
68
|
-
'
|
69
|
-
|
70
|
-
})
|
82
|
+
'summary': help,
|
83
|
+
'selectors': cssSelector,
|
84
|
+
'url': helpUrl
|
71
85
|
}
|
72
86
|
})
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
'url': helpUrl
|
78
|
-
}
|
79
|
-
})
|
80
|
-
)
|
87
|
+
)
|
88
|
+
} else {
|
89
|
+
return false
|
90
|
+
}
|
81
91
|
}
|
82
92
|
|
83
93
|
var _formatHelpUrl = function (helpUrl) {
|
@@ -143,7 +153,7 @@
|
|
143
153
|
document.addEventListener('DOMContentLoaded', function () {
|
144
154
|
AccessibilityTest('[data-module="test-a11y"]', function (err, violations, incompleteWarnings) {
|
145
155
|
if (err) {
|
146
|
-
|
156
|
+
_throwUncaughtError(err)
|
147
157
|
}
|
148
158
|
if (incompleteWarnings) _renderIncompleteWarnings(incompleteWarnings)
|
149
159
|
if (violations) _throwUncaughtError(violations)
|
@@ -6,6 +6,7 @@ module GovukPublishingComponents
|
|
6
6
|
protect_from_forgery with: :exception
|
7
7
|
before_action :set_custom_slimmer_headers
|
8
8
|
before_action :set_x_frame_options_header
|
9
|
+
before_action :set_no_banner_cookie
|
9
10
|
|
10
11
|
private
|
11
12
|
|
@@ -16,5 +17,19 @@ module GovukPublishingComponents
|
|
16
17
|
def set_x_frame_options_header
|
17
18
|
response.headers["X-Frame-Options"] = "ALLOWALL"
|
18
19
|
end
|
20
|
+
|
21
|
+
def set_no_banner_cookie
|
22
|
+
cookies['govuk_takenUserSatisfactionSurvey'] = {
|
23
|
+
value: 'yes',
|
24
|
+
domain: 'localhost',
|
25
|
+
path: '/component-guide'
|
26
|
+
}
|
27
|
+
|
28
|
+
cookies['seen_cookie_message'] = {
|
29
|
+
value: 'yes',
|
30
|
+
domain: 'localhost',
|
31
|
+
path: '/component-guide'
|
32
|
+
}
|
33
|
+
end
|
19
34
|
end
|
20
35
|
end
|
@@ -7,7 +7,7 @@ Links in the component must:
|
|
7
7
|
- accept focus
|
8
8
|
- be focusable with a keyboard
|
9
9
|
- be usable with a keyboard
|
10
|
-
- indicate when
|
10
|
+
- indicate when they have focus
|
11
11
|
- change in appearance when touched (in the touch-down state)
|
12
12
|
- change in appearance when hovered
|
13
13
|
- be usable with touch
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_publishing_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|