govuk_publishing_components 9.6.0 → 9.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/radio.js +32 -0
  3. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -1
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_back-link.scss +4 -31
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +13 -42
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +4 -32
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_label.scss +4 -23
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +0 -8
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_radio.scss +5 -129
  10. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss +5 -3
  11. data/app/views/govuk_publishing_components/components/_back_link.html.erb +7 -6
  12. data/app/views/govuk_publishing_components/components/_button.html.erb +2 -2
  13. data/app/views/govuk_publishing_components/components/_input.html.erb +32 -25
  14. data/app/views/govuk_publishing_components/components/_label.html.erb +13 -31
  15. data/app/views/govuk_publishing_components/components/_radio.html.erb +54 -38
  16. data/app/views/govuk_publishing_components/components/docs/radio.yml +14 -2
  17. data/lib/govuk_publishing_components/version.rb +1 -1
  18. data/node_modules/govuk-frontend/all.js +172 -172
  19. data/node_modules/govuk-frontend/components/checkboxes/README.md +92 -4
  20. data/node_modules/govuk-frontend/components/checkboxes/_checkboxes.scss +7 -1
  21. data/node_modules/govuk-frontend/components/checkboxes/checkboxes.js +356 -1
  22. data/node_modules/govuk-frontend/components/checkboxes/template.njk +15 -3
  23. data/node_modules/govuk-frontend/components/date-input/README.md +3 -3
  24. data/node_modules/govuk-frontend/components/file-upload/README.md +3 -3
  25. data/node_modules/govuk-frontend/components/header/_header.scss +5 -3
  26. data/node_modules/govuk-frontend/components/input/README.md +3 -3
  27. data/node_modules/govuk-frontend/components/phase-banner/README.md +1 -1
  28. data/node_modules/govuk-frontend/components/radios/README.md +176 -3
  29. data/node_modules/govuk-frontend/components/radios/_radios.scss +15 -1
  30. data/node_modules/govuk-frontend/components/radios/radios.js +356 -1
  31. data/node_modules/govuk-frontend/components/radios/template.njk +19 -3
  32. data/node_modules/govuk-frontend/components/select/README.md +3 -3
  33. data/node_modules/govuk-frontend/components/tabs/_tabs.scss +4 -4
  34. data/node_modules/govuk-frontend/components/tabs/tabs.js +1 -1
  35. data/node_modules/govuk-frontend/components/textarea/README.md +3 -3
  36. data/node_modules/govuk-frontend/package.json +18 -18
  37. data/node_modules/govuk-frontend/template.njk +4 -2
  38. data/node_modules/govuk-frontend/tools/_font-url.scss +1 -1
  39. data/node_modules/govuk-frontend/tools/_image-url.scss +1 -1
  40. metadata +3 -2
@@ -48,21 +48,33 @@
48
48
  {% set id = item.id if item.id else idPrefix + "-" + loop.index %}
49
49
  {% set name = item.name if item.name else params.name %}
50
50
  {% set conditionalId = "conditional-" + id %}
51
+ {% set hasHint = true if item.hint.text or item.hint.html %}
52
+ {% set itemHintId = id + '-item-hint' %}
51
53
  <div class="govuk-checkboxes__item">
52
54
  <input class="govuk-checkboxes__input" id="{{ id }}" name="{{ name }}" type="checkbox" value="{{ item.value }}"
53
55
  {{-" checked" if item.checked }}
54
56
  {{-" disabled" if item.disabled }}
55
- {%- if item.conditional %} data-aria-controls="{{ conditionalId }}"{% endif -%}>
57
+ {%- if item.conditional %} data-aria-controls="{{ conditionalId }}"{% endif -%}
58
+ {%- if hasHint %} aria-describedby="{{ itemHintId }}"{% endif -%}>
56
59
  {{ govukLabel({
57
60
  html: item.html,
58
61
  text: item.text,
59
- classes: 'govuk-checkboxes__label',
62
+ classes: 'govuk-checkboxes__label' + (' ' + item.label.classes if item.label.classes),
60
63
  attributes: item.label.attributes,
61
64
  for: id
62
65
  }) | indent(6) | trim }}
66
+ {%- if hasHint %}
67
+ {{ govukHint({
68
+ id: itemHintId,
69
+ classes: 'govuk-checkboxes__hint',
70
+ attributes: item.hint.attributes,
71
+ html: item.hint.html,
72
+ text: item.hint.text
73
+ }) | indent(6) | trim }}
74
+ {%- endif %}
63
75
  </div>
64
76
  {% if item.conditional %}
65
- <div class="govuk-checkboxes__conditional" id="{{ conditionalId }}">
77
+ <div class="govuk-checkboxes__conditional{% if not item.checked %} govuk-checkboxes__conditional--hidden{% endif %}" id="{{ conditionalId }}">
66
78
  {{ item.conditional.html | safe }}
67
79
  </div>
68
80
  {% endif %}
@@ -655,7 +655,7 @@ If you are using Nunjucks,then macros take the following arguments
655
655
 
656
656
  <td class="govuk-table__cell ">No</td>
657
657
 
658
- <td class="govuk-table__cell ">Optional hint. See hint component.</td>
658
+ <td class="govuk-table__cell ">Optional hint. See <a href="../hint/README.md#component-arguments">hint</a> component.</td>
659
659
 
660
660
  </tr>
661
661
 
@@ -667,7 +667,7 @@ If you are using Nunjucks,then macros take the following arguments
667
667
 
668
668
  <td class="govuk-table__cell ">No</td>
669
669
 
670
- <td class="govuk-table__cell ">Optional error message. See errorMessage component.</td>
670
+ <td class="govuk-table__cell ">Optional error message. See <a href="../error-message/README.md#component-arguments">errorMessage</a> component.</td>
671
671
 
672
672
  </tr>
673
673
 
@@ -679,7 +679,7 @@ If you are using Nunjucks,then macros take the following arguments
679
679
 
680
680
  <td class="govuk-table__cell ">No</td>
681
681
 
682
- <td class="govuk-table__cell ">Arguments for the fieldset component (e.g. legend). See fieldset component.</td>
682
+ <td class="govuk-table__cell ">Arguments for the fieldset component (e.g. legend). See <a href="../fieldset/README.md#component-arguments">fieldset</a> component.</td>
683
683
 
684
684
  </tr>
685
685
 
@@ -255,7 +255,7 @@ If you are using Nunjucks,then macros take the following arguments
255
255
 
256
256
  <td class="govuk-table__cell ">Yes</td>
257
257
 
258
- <td class="govuk-table__cell ">Arguments for the label component. See label component.</td>
258
+ <td class="govuk-table__cell ">Arguments for the label component. See <a href="../label/README.md#component-arguments">label</a> component.</td>
259
259
 
260
260
  </tr>
261
261
 
@@ -267,7 +267,7 @@ If you are using Nunjucks,then macros take the following arguments
267
267
 
268
268
  <td class="govuk-table__cell ">No</td>
269
269
 
270
- <td class="govuk-table__cell ">Arguments for the hint component (e.g. text). See hint component.</td>
270
+ <td class="govuk-table__cell ">Arguments for the hint component (e.g. text). See <a href="../hint/README.md#component-arguments">hint</a> component.</td>
271
271
 
272
272
  </tr>
273
273
 
@@ -279,7 +279,7 @@ If you are using Nunjucks,then macros take the following arguments
279
279
 
280
280
  <td class="govuk-table__cell ">No</td>
281
281
 
282
- <td class="govuk-table__cell ">Arguments for the errorMessage component (e.g. text). See errorMessage component.</td>
282
+ <td class="govuk-table__cell ">Arguments for the errorMessage component (e.g. text). See <a href="../error-message/README.md#component-arguments">errorMessage</a> component.</td>
283
283
 
284
284
  </tr>
285
285
 
@@ -101,14 +101,16 @@
101
101
 
102
102
  &:link,
103
103
  &:visited {
104
- margin-bottom: -1px; // Negate transparent bottom border
105
- border-bottom: 1px solid transparent;
106
104
  text-decoration: none;
107
105
  }
108
106
 
109
107
  &:hover,
110
108
  &:active {
111
- border-bottom-color: currentColor;
109
+ // Negate the added border
110
+ margin-bottom: -1px;
111
+ // Omitting colour will use default value of currentColor – if we
112
+ // specified currentColor explicitly IE8 would ignore this rule.
113
+ border-bottom: 1px solid;
112
114
  }
113
115
  }
114
116
 
@@ -475,7 +475,7 @@ If you are using Nunjucks,then macros take the following arguments
475
475
 
476
476
  <td class="govuk-table__cell ">No</td>
477
477
 
478
- <td class="govuk-table__cell ">Arguments for the label component. See label component.</td>
478
+ <td class="govuk-table__cell ">Arguments for the label component. See <a href="../label/README.md#component-arguments">label</a> component.</td>
479
479
 
480
480
  </tr>
481
481
 
@@ -487,7 +487,7 @@ If you are using Nunjucks,then macros take the following arguments
487
487
 
488
488
  <td class="govuk-table__cell ">No</td>
489
489
 
490
- <td class="govuk-table__cell ">Arguments for the hint component (e.g. text). See hint component.</td>
490
+ <td class="govuk-table__cell ">Arguments for the hint component (e.g. text). See <a href="../hint/README.md#component-arguments">hint</a> component.</td>
491
491
 
492
492
  </tr>
493
493
 
@@ -499,7 +499,7 @@ If you are using Nunjucks,then macros take the following arguments
499
499
 
500
500
  <td class="govuk-table__cell ">No</td>
501
501
 
502
- <td class="govuk-table__cell ">Arguments for the errorMessage component (e.g. text). See errorMessage component.</td>
502
+ <td class="govuk-table__cell ">Arguments for the errorMessage component (e.g. text). See <a href="../error-message/README.md#component-arguments">errorMessage</a> component.</td>
503
503
 
504
504
  </tr>
505
505
 
@@ -99,7 +99,7 @@ If you are using Nunjucks,then macros take the following arguments
99
99
 
100
100
  <td class="govuk-table__cell ">No</td>
101
101
 
102
- <td class="govuk-table__cell ">Arguments for the tag object. See tag component.</td>
102
+ <td class="govuk-table__cell ">Arguments for the tag object. See <a href="../tag/README.md#component-arguments">tag</a> component.</td>
103
103
 
104
104
  </tr>
105
105
 
@@ -350,6 +350,155 @@ Find out when to use the radios component in your service in the [GOV.UK Design
350
350
  ]
351
351
  }) }}
352
352
 
353
+ ### Radios with a divider
354
+
355
+ [Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/radios/with-a-divider/preview)
356
+
357
+ #### Markup
358
+
359
+ <div class="govuk-form-group">
360
+
361
+ <fieldset class="govuk-fieldset">
362
+
363
+ <legend class="govuk-fieldset__legend">
364
+ How do you want to sign in?
365
+ </legend>
366
+
367
+ <div class="govuk-radios">
368
+
369
+ <div class="govuk-radios__item">
370
+ <input class="govuk-radios__input" id="example-divider-1" name="example" type="radio" value="governement-gateway">
371
+ <label class="govuk-label govuk-radios__label" for="example-divider-1">
372
+ Use Government Gateway
373
+ </label>
374
+ </div>
375
+
376
+ <div class="govuk-radios__item">
377
+ <input class="govuk-radios__input" id="example-divider-2" name="example" type="radio" value="govuk-verify">
378
+ <label class="govuk-label govuk-radios__label" for="example-divider-2">
379
+ Use GOV.UK Verify
380
+ </label>
381
+ </div>
382
+
383
+ <div class="govuk-radios__divider">or</div>
384
+
385
+ <div class="govuk-radios__item">
386
+ <input class="govuk-radios__input" id="example-divider-4" name="example" type="radio" value="create-account">
387
+ <label class="govuk-label govuk-radios__label" for="example-divider-4">
388
+ Create an account
389
+ </label>
390
+ </div>
391
+
392
+ </div>
393
+ </fieldset>
394
+
395
+ </div>
396
+
397
+ #### Macro
398
+
399
+ {% from "radios/macro.njk" import govukRadios %}
400
+
401
+ {{ govukRadios({
402
+ "idPrefix": "example-divider",
403
+ "name": "example",
404
+ "fieldset": {
405
+ "legend": {
406
+ "text": "How do you want to sign in?"
407
+ }
408
+ },
409
+ "items": [
410
+ {
411
+ "value": "governement-gateway",
412
+ "text": "Use Government Gateway"
413
+ },
414
+ {
415
+ "value": "govuk-verify",
416
+ "text": "Use GOV.UK Verify"
417
+ },
418
+ {
419
+ "divider": "or"
420
+ },
421
+ {
422
+ "value": "create-account",
423
+ "text": "Create an account"
424
+ }
425
+ ]
426
+ }) }}
427
+
428
+ ### Radios with hints on items
429
+
430
+ [Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/radios/with-hints-on-items/preview)
431
+
432
+ #### Markup
433
+
434
+ <div class="govuk-form-group">
435
+
436
+ <fieldset class="govuk-fieldset">
437
+
438
+ <legend class="govuk-fieldset__legend">
439
+ <h1 class="govuk-fieldset__heading">
440
+ How do you want to sign in?
441
+ </h1>
442
+ </legend>
443
+
444
+ <div class="govuk-radios">
445
+
446
+ <div class="govuk-radios__item">
447
+ <input class="govuk-radios__input" id="gov-1" name="gov" type="radio" value="gateway" aria-describedby="gov-1-item-hint">
448
+ <label class="govuk-label govuk-radios__label" for="gov-1">
449
+ Sign in with Government Gateway
450
+ </label>
451
+ <span id="gov-1-item-hint" class="govuk-hint govuk-radios__hint">
452
+ You&#39;ll have a user ID if you&#39;ve registered for Self Assessment or filed a tax return online before.
453
+ </span>
454
+ </div>
455
+
456
+ <div class="govuk-radios__item">
457
+ <input class="govuk-radios__input" id="gov-2" name="gov" type="radio" value="verify" aria-describedby="gov-2-item-hint">
458
+ <label class="govuk-label govuk-radios__label" for="gov-2">
459
+ Sign in with GOV.UK Verify
460
+ </label>
461
+ <span id="gov-2-item-hint" class="govuk-hint govuk-radios__hint">
462
+ You’ll have an account if you’ve already proved your identity with either Barclays, CitizenSafe, Digidentity, Experian, Post Office, Royal Mail or SecureIdentity.
463
+ </span>
464
+ </div>
465
+
466
+ </div>
467
+ </fieldset>
468
+
469
+ </div>
470
+
471
+ #### Macro
472
+
473
+ {% from "radios/macro.njk" import govukRadios %}
474
+
475
+ {{ govukRadios({
476
+ "idPrefix": "gov",
477
+ "name": "gov",
478
+ "fieldset": {
479
+ "legend": {
480
+ "text": "How do you want to sign in?",
481
+ "isPageHeading": true
482
+ }
483
+ },
484
+ "items": [
485
+ {
486
+ "value": "gateway",
487
+ "text": "Sign in with Government Gateway",
488
+ "hint": {
489
+ "text": "You'll have a user ID if you've registered for Self Assessment or filed a tax return online before."
490
+ }
491
+ },
492
+ {
493
+ "value": "verify",
494
+ "text": "Sign in with GOV.UK Verify",
495
+ "hint": {
496
+ "text": "You’ll have an account if you’ve already proved your identity with either Barclays, CitizenSafe, Digidentity, Experian, Post Office, Royal Mail or SecureIdentity."
497
+ }
498
+ }
499
+ ]
500
+ }) }}
501
+
353
502
  ### Radios without fieldset
354
503
 
355
504
  [Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/radios/without-fieldset/preview)
@@ -536,7 +685,7 @@ If you are using Nunjucks,then macros take the following arguments
536
685
 
537
686
  <td class="govuk-table__cell ">No</td>
538
687
 
539
- <td class="govuk-table__cell ">Arguments for the fieldset component (e.g. legend). See fieldset component.</td>
688
+ <td class="govuk-table__cell ">Arguments for the fieldset component (e.g. legend). See <a href="../fieldset/README.md#component-arguments">fieldset</a> component.</td>
540
689
 
541
690
  </tr>
542
691
 
@@ -548,7 +697,7 @@ If you are using Nunjucks,then macros take the following arguments
548
697
 
549
698
  <td class="govuk-table__cell ">No</td>
550
699
 
551
- <td class="govuk-table__cell ">Arguments for the hint component (e.g. text). See hint component.</td>
700
+ <td class="govuk-table__cell ">Arguments for the hint component (e.g. text). See <a href="../hint/README.md#component-arguments">hint</a> component.</td>
552
701
 
553
702
  </tr>
554
703
 
@@ -656,7 +805,31 @@ If you are using Nunjucks,then macros take the following arguments
656
805
 
657
806
  <td class="govuk-table__cell ">No</td>
658
807
 
659
- <td class="govuk-table__cell ">Provide additional attributes to each radio item label. See `label` component for more details.</td>
808
+ <td class="govuk-table__cell ">Provide additional attributes and classes to each radio item label. See [label](../label/README.md#component-arguments) component for more details.</td>
809
+
810
+ </tr>
811
+
812
+ <tr class="govuk-table__row">
813
+
814
+ <th class="govuk-table__header" scope="row">items.{}.hint</th>
815
+
816
+ <td class="govuk-table__cell ">object</td>
817
+
818
+ <td class="govuk-table__cell ">No</td>
819
+
820
+ <td class="govuk-table__cell ">Provide optional hint to each radio item. See `hint` component for more details.</td>
821
+
822
+ </tr>
823
+
824
+ <tr class="govuk-table__row">
825
+
826
+ <th class="govuk-table__header" scope="row">items.{}.divider</th>
827
+
828
+ <td class="govuk-table__cell ">string</td>
829
+
830
+ <td class="govuk-table__cell ">No</td>
831
+
832
+ <td class="govuk-table__cell ">Optional divider text to separate radio items, for example the text "or".</td>
660
833
 
661
834
  </tr>
662
835
 
@@ -70,6 +70,12 @@
70
70
  touch-action: manipulation;
71
71
  }
72
72
 
73
+ .govuk-radios__hint {
74
+ display: block;
75
+ padding-right: $govuk-radios-label-padding-left-right;
76
+ padding-left: $govuk-radios-label-padding-left-right;
77
+ }
78
+
73
79
  .govuk-radios__input + .govuk-radios__label::before {
74
80
  content: "";
75
81
  -webkit-box-sizing: border-box;
@@ -141,6 +147,14 @@
141
147
  }
142
148
  }
143
149
 
150
+ .govuk-radios__divider {
151
+ $govuk-divider-size: $govuk-radios-size !default;
152
+ @include govuk-font($size: 19);
153
+ width: $govuk-divider-size;
154
+ margin-bottom: govuk-spacing(2);
155
+ text-align: center;
156
+ }
157
+
144
158
  $conditional-border-width: $govuk-border-width-mobile;
145
159
  // Calculate the amount of padding needed to keep the border centered against the radios.
146
160
  $conditional-border-padding: ($govuk-radios-size / 2) - ($conditional-border-width / 2);
@@ -155,7 +169,7 @@
155
169
  padding-left: $conditional-padding-left;
156
170
  border-left: $conditional-border-width solid $govuk-border-colour;
157
171
 
158
- &[aria-hidden="true"] {
172
+ .js-enabled &--hidden {
159
173
  display: none;
160
174
  }
161
175
 
@@ -659,6 +659,361 @@ if (detect) return
659
659
  })
660
660
  .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
661
661
 
662
+ (function(undefined) {
663
+
664
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
665
+ var detect = (
666
+ 'DOMTokenList' in this && (function (x) {
667
+ return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
668
+ })(document.createElement('x'))
669
+ );
670
+
671
+ if (detect) return
672
+
673
+ // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
674
+ (function (global) {
675
+ var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
676
+
677
+ if (
678
+ !nativeImpl ||
679
+ (
680
+ !!document.createElementNS &&
681
+ !!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
682
+ !(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
683
+ )
684
+ ) {
685
+ global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
686
+ var dpSupport = true;
687
+ var defineGetter = function (object, name, fn, configurable) {
688
+ if (Object.defineProperty)
689
+ Object.defineProperty(object, name, {
690
+ configurable: false === dpSupport ? true : !!configurable,
691
+ get: fn
692
+ });
693
+
694
+ else object.__defineGetter__(name, fn);
695
+ };
696
+
697
+ /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
698
+ try {
699
+ defineGetter({}, "support");
700
+ }
701
+ catch (e) {
702
+ dpSupport = false;
703
+ }
704
+
705
+
706
+ var _DOMTokenList = function (el, prop) {
707
+ var that = this;
708
+ var tokens = [];
709
+ var tokenMap = {};
710
+ var length = 0;
711
+ var maxLength = 0;
712
+ var addIndexGetter = function (i) {
713
+ defineGetter(that, i, function () {
714
+ preop();
715
+ return tokens[i];
716
+ }, false);
717
+
718
+ };
719
+ var reindex = function () {
720
+
721
+ /** Define getter functions for array-like access to the tokenList's contents. */
722
+ if (length >= maxLength)
723
+ for (; maxLength < length; ++maxLength) {
724
+ addIndexGetter(maxLength);
725
+ }
726
+ };
727
+
728
+ /** Helper function called at the start of each class method. Internal use only. */
729
+ var preop = function () {
730
+ var error;
731
+ var i;
732
+ var args = arguments;
733
+ var rSpace = /\s+/;
734
+
735
+ /** Validate the token/s passed to an instance method, if any. */
736
+ if (args.length)
737
+ for (i = 0; i < args.length; ++i)
738
+ if (rSpace.test(args[i])) {
739
+ error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
740
+ error.code = 5;
741
+ error.name = "InvalidCharacterError";
742
+ throw error;
743
+ }
744
+
745
+
746
+ /** Split the new value apart by whitespace*/
747
+ if (typeof el[prop] === "object") {
748
+ tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
749
+ } else {
750
+ tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
751
+ }
752
+
753
+ /** Avoid treating blank strings as single-item token lists */
754
+ if ("" === tokens[0]) tokens = [];
755
+
756
+ /** Repopulate the internal token lists */
757
+ tokenMap = {};
758
+ for (i = 0; i < tokens.length; ++i)
759
+ tokenMap[tokens[i]] = true;
760
+ length = tokens.length;
761
+ reindex();
762
+ };
763
+
764
+ /** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
765
+ preop();
766
+
767
+ /** Return the number of tokens in the underlying string. Read-only. */
768
+ defineGetter(that, "length", function () {
769
+ preop();
770
+ return length;
771
+ });
772
+
773
+ /** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
774
+ that.toLocaleString =
775
+ that.toString = function () {
776
+ preop();
777
+ return tokens.join(" ");
778
+ };
779
+
780
+ that.item = function (idx) {
781
+ preop();
782
+ return tokens[idx];
783
+ };
784
+
785
+ that.contains = function (token) {
786
+ preop();
787
+ return !!tokenMap[token];
788
+ };
789
+
790
+ that.add = function () {
791
+ preop.apply(that, args = arguments);
792
+
793
+ for (var args, token, i = 0, l = args.length; i < l; ++i) {
794
+ token = args[i];
795
+ if (!tokenMap[token]) {
796
+ tokens.push(token);
797
+ tokenMap[token] = true;
798
+ }
799
+ }
800
+
801
+ /** Update the targeted attribute of the attached element if the token list's changed. */
802
+ if (length !== tokens.length) {
803
+ length = tokens.length >>> 0;
804
+ if (typeof el[prop] === "object") {
805
+ el[prop].baseVal = tokens.join(" ");
806
+ } else {
807
+ el[prop] = tokens.join(" ");
808
+ }
809
+ reindex();
810
+ }
811
+ };
812
+
813
+ that.remove = function () {
814
+ preop.apply(that, args = arguments);
815
+
816
+ /** Build a hash of token names to compare against when recollecting our token list. */
817
+ for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
818
+ ignore[args[i]] = true;
819
+ delete tokenMap[args[i]];
820
+ }
821
+
822
+ /** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
823
+ for (i = 0; i < tokens.length; ++i)
824
+ if (!ignore[tokens[i]]) t.push(tokens[i]);
825
+
826
+ tokens = t;
827
+ length = t.length >>> 0;
828
+
829
+ /** Update the targeted attribute of the attached element. */
830
+ if (typeof el[prop] === "object") {
831
+ el[prop].baseVal = tokens.join(" ");
832
+ } else {
833
+ el[prop] = tokens.join(" ");
834
+ }
835
+ reindex();
836
+ };
837
+
838
+ that.toggle = function (token, force) {
839
+ preop.apply(that, [token]);
840
+
841
+ /** Token state's being forced. */
842
+ if (undefined !== force) {
843
+ if (force) {
844
+ that.add(token);
845
+ return true;
846
+ } else {
847
+ that.remove(token);
848
+ return false;
849
+ }
850
+ }
851
+
852
+ /** Token already exists in tokenList. Remove it, and return FALSE. */
853
+ if (tokenMap[token]) {
854
+ that.remove(token);
855
+ return false;
856
+ }
857
+
858
+ /** Otherwise, add the token and return TRUE. */
859
+ that.add(token);
860
+ return true;
861
+ };
862
+
863
+ return that;
864
+ };
865
+
866
+ return _DOMTokenList;
867
+ }());
868
+ }
869
+
870
+ // Add second argument to native DOMTokenList.toggle() if necessary
871
+ (function () {
872
+ var e = document.createElement('span');
873
+ if (!('classList' in e)) return;
874
+ e.classList.toggle('x', false);
875
+ if (!e.classList.contains('x')) return;
876
+ e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
877
+ var force = arguments[1];
878
+ if (force === undefined) {
879
+ var add = !this.contains(token);
880
+ this[add ? 'add' : 'remove'](token);
881
+ return add;
882
+ }
883
+ force = !!force;
884
+ this[force ? 'add' : 'remove'](token);
885
+ return force;
886
+ };
887
+ }());
888
+
889
+ // Add multiple arguments to native DOMTokenList.add() if necessary
890
+ (function () {
891
+ var e = document.createElement('span');
892
+ if (!('classList' in e)) return;
893
+ e.classList.add('a', 'b');
894
+ if (e.classList.contains('b')) return;
895
+ var native = e.classList.constructor.prototype.add;
896
+ e.classList.constructor.prototype.add = function () {
897
+ var args = arguments;
898
+ var l = arguments.length;
899
+ for (var i = 0; i < l; i++) {
900
+ native.call(this, args[i]);
901
+ }
902
+ };
903
+ }());
904
+
905
+ // Add multiple arguments to native DOMTokenList.remove() if necessary
906
+ (function () {
907
+ var e = document.createElement('span');
908
+ if (!('classList' in e)) return;
909
+ e.classList.add('a');
910
+ e.classList.add('b');
911
+ e.classList.remove('a', 'b');
912
+ if (!e.classList.contains('b')) return;
913
+ var native = e.classList.constructor.prototype.remove;
914
+ e.classList.constructor.prototype.remove = function () {
915
+ var args = arguments;
916
+ var l = arguments.length;
917
+ for (var i = 0; i < l; i++) {
918
+ native.call(this, args[i]);
919
+ }
920
+ };
921
+ }());
922
+
923
+ }(this));
924
+
925
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
926
+
927
+ (function(undefined) {
928
+
929
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
930
+ var detect = (
931
+ 'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
932
+ var e = document.createElement('span');
933
+ e.classList.add('a', 'b');
934
+ return e.classList.contains('b');
935
+ }())
936
+ );
937
+
938
+ if (detect) return
939
+
940
+ // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/polyfill.js
941
+ (function (global) {
942
+ var dpSupport = true;
943
+ var defineGetter = function (object, name, fn, configurable) {
944
+ if (Object.defineProperty)
945
+ Object.defineProperty(object, name, {
946
+ configurable: false === dpSupport ? true : !!configurable,
947
+ get: fn
948
+ });
949
+
950
+ else object.__defineGetter__(name, fn);
951
+ };
952
+ /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
953
+ try {
954
+ defineGetter({}, "support");
955
+ }
956
+ catch (e) {
957
+ dpSupport = false;
958
+ }
959
+ /** Polyfills a property with a DOMTokenList */
960
+ var addProp = function (o, name, attr) {
961
+
962
+ defineGetter(o.prototype, name, function () {
963
+ var tokenList;
964
+
965
+ var THIS = this,
966
+
967
+ /** Prevent this from firing twice for some reason. What the hell, IE. */
968
+ gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
969
+ if(THIS[gibberishProperty]) return tokenList;
970
+ THIS[gibberishProperty] = true;
971
+
972
+ /**
973
+ * IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
974
+ *
975
+ * What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
976
+ * that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
977
+ * element instead, this would conflict with element types which use indexed properties (such as forms and
978
+ * select lists).
979
+ */
980
+ if (false === dpSupport) {
981
+
982
+ var visage;
983
+ var mirror = addProp.mirror || document.createElement("div");
984
+ var reflections = mirror.childNodes;
985
+ var l = reflections.length;
986
+
987
+ for (var i = 0; i < l; ++i)
988
+ if (reflections[i]._R === THIS) {
989
+ visage = reflections[i];
990
+ break;
991
+ }
992
+
993
+ /** Couldn't find an element's reflection inside the mirror. Materialise one. */
994
+ visage || (visage = mirror.appendChild(document.createElement("div")));
995
+
996
+ tokenList = DOMTokenList.call(visage, THIS, attr);
997
+ } else tokenList = new DOMTokenList(THIS, attr);
998
+
999
+ defineGetter(THIS, name, function () {
1000
+ return tokenList;
1001
+ });
1002
+ delete THIS[gibberishProperty];
1003
+
1004
+ return tokenList;
1005
+ }, true);
1006
+ };
1007
+
1008
+ addProp(global.Element, "classList", "className");
1009
+ addProp(global.HTMLElement, "classList", "className");
1010
+ addProp(global.HTMLLinkElement, "relList", "rel");
1011
+ addProp(global.HTMLAnchorElement, "relList", "rel");
1012
+ addProp(global.HTMLAreaElement, "relList", "rel");
1013
+ }(this));
1014
+
1015
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1016
+
662
1017
  /**
663
1018
  * TODO: Ideally this would be a NodeList.prototype.forEach polyfill
664
1019
  * This seems to fail in IE8, requires more investigation.
@@ -711,7 +1066,7 @@ Radios.prototype.setAttributes = function ($input) {
711
1066
  $input.setAttribute('aria-expanded', inputIsChecked);
712
1067
 
713
1068
  var $content = document.querySelector('#' + $input.getAttribute('aria-controls'));
714
- $content.setAttribute('aria-hidden', !inputIsChecked);
1069
+ $content.classList.toggle('govuk-radios__conditional--hidden', !inputIsChecked);
715
1070
  };
716
1071
 
717
1072
  Radios.prototype.handleClick = function (event) {