govuk_publishing_components 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8d9bbd3501a6dc341847fe5f7e1e55862a12a26
4
- data.tar.gz: c17cb2fca96844fd7d3038656550fba5cd378e9a
3
+ metadata.gz: c89ac97d233cfea87960f74561b440b7b512f4f5
4
+ data.tar.gz: 8eead0093c99748abd32686edd8e7f664f8485d4
5
5
  SHA512:
6
- metadata.gz: f608ae560744b49d350b8d72b3ee0062a2ea899ddb76cb0219cf941d8e92336d4681695bb145d810e83670bb64afc5382eb010aa49ceba5a7e72036a68a70eb6
7
- data.tar.gz: a2f28ab4fd0aae15e63479a7e2b5afe2c7ee819726bbddd954555b294a973f08f6413f352923e7b66c341f6d5b137effdf741703ed1e2e43a875d9526623fc9d
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('No selector "' + selector + '" found')
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
- var violations = (typeof results === 'undefined') ? [] : results.violations
24
- var incompleteWarnings = (typeof results === 'undefined') ? [] : results.incomplete
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 incompleteWarningsObj = _processIncompleteWarnings(incompleteWarnings)
31
- var errorText = _processViolations(violations, results.url)
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
- else {
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
- return (
62
- incompleteWarnings.map(function (incomplete) {
63
- var help = incomplete.help
64
- var helpUrl = _formatHelpUrl(incomplete.helpUrl)
65
- var cssSelector = incomplete.nodes.map(function (node) {
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
- 'selector': node.target,
68
- 'reason': node.any.map(function(item) {
69
- return item.message
70
- })
82
+ 'summary': help,
83
+ 'selectors': cssSelector,
84
+ 'url': helpUrl
71
85
  }
72
86
  })
73
-
74
- return {
75
- 'summary': help,
76
- 'selectors': cssSelector,
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
- return
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 it has focus
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
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '1.6.0'.freeze
2
+ VERSION = '1.7.0'.freeze
3
3
  end
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.6.0
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-13 00:00:00.000000000 Z
11
+ date: 2017-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails