govuk_publishing_components 34.7.0 → 34.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +0 -7
  3. data/lib/govuk_publishing_components/version.rb +1 -1
  4. data/node_modules/govuk-frontend/govuk/all.js +4029 -3792
  5. data/node_modules/govuk-frontend/govuk/all.js.map +1 -0
  6. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +52 -51
  7. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js.map +1 -0
  8. data/node_modules/govuk-frontend/govuk/common/index.js +153 -145
  9. data/node_modules/govuk-frontend/govuk/common/index.js.map +1 -0
  10. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +324 -321
  11. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js.map +1 -0
  12. data/node_modules/govuk-frontend/govuk/common.js +154 -146
  13. data/node_modules/govuk-frontend/govuk/common.js.map +1 -0
  14. data/node_modules/govuk-frontend/govuk/components/_all.scss +1 -1
  15. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +23 -4
  16. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +2059 -1654
  17. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js.map +1 -0
  18. data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +11 -11
  19. data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +1 -1
  20. data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +19 -19
  21. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +21 -10
  22. data/node_modules/govuk-frontend/govuk/components/button/button.js +927 -917
  23. data/node_modules/govuk-frontend/govuk/components/button/button.js.map +1 -0
  24. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +2050 -2040
  25. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js.map +1 -0
  26. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +1155 -1147
  27. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js.map +1 -0
  28. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +23 -23
  29. data/node_modules/govuk-frontend/govuk/components/cookie-banner/template.njk +1 -1
  30. data/node_modules/govuk-frontend/govuk/components/details/details.js +800 -799
  31. data/node_modules/govuk-frontend/govuk/components/details/details.js.map +1 -0
  32. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +1058 -1045
  33. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js.map +1 -0
  34. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +6 -0
  35. data/node_modules/govuk-frontend/govuk/components/header/header.js +646 -998
  36. data/node_modules/govuk-frontend/govuk/components/header/header.js.map +1 -0
  37. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +760 -752
  38. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js.map +1 -0
  39. data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +61 -0
  40. data/node_modules/govuk-frontend/govuk/components/pagination/template.njk +1 -1
  41. data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +1 -1
  42. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +1110 -1107
  43. data/node_modules/govuk-frontend/govuk/components/radios/radios.js.map +1 -0
  44. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1017 -1014
  45. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js.map +1 -0
  46. data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +107 -0
  47. data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +318 -23
  48. data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +110 -0
  49. data/node_modules/govuk-frontend/govuk/components/summary-list/template.njk +72 -28
  50. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +1392 -1264
  51. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js.map +1 -0
  52. data/node_modules/govuk-frontend/govuk/i18n.js +363 -364
  53. data/node_modules/govuk-frontend/govuk/i18n.js.map +1 -0
  54. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +5 -5
  55. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +242 -241
  56. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js.map +1 -0
  57. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +13 -12
  58. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js.map +1 -0
  59. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +17 -16
  60. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js.map +1 -0
  61. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +547 -546
  62. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js.map +1 -0
  63. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +37 -36
  64. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js.map +1 -0
  65. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +251 -250
  66. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js.map +1 -0
  67. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +21 -20
  68. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js.map +1 -0
  69. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +198 -197
  70. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js.map +1 -0
  71. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +198 -197
  72. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js.map +1 -0
  73. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +106 -105
  74. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js.map +1 -0
  75. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +400 -399
  76. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js.map +1 -0
  77. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +239 -238
  78. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js.map +1 -0
  79. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +72 -71
  80. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js.map +1 -0
  81. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +14 -13
  82. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js.map +1 -0
  83. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +17 -16
  84. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js.map +1 -0
  85. data/node_modules/govuk-frontend/govuk-esm/all.mjs +2 -2
  86. data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +17 -10
  87. data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +3 -1
  88. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +135 -52
  89. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +11 -9
  90. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +10 -7
  91. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +24 -18
  92. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +23 -16
  93. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +15 -11
  94. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +3 -2
  95. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +3 -4
  96. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +10 -9
  97. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +5 -3
  98. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +165 -38
  99. data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +9 -11
  100. data/node_modules/govuk-frontend/package.json +1 -1
  101. metadata +34 -2
@@ -4,1111 +4,1114 @@
4
4
  (global.GOVUKFrontend = global.GOVUKFrontend || {}, global.GOVUKFrontend.SkipLink = factory());
5
5
  }(this, (function () { 'use strict';
6
6
 
7
- (function(undefined) {
8
-
9
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
10
- var detect = (
11
- // In IE8, defineProperty could only act on DOM elements, so full support
12
- // for the feature requires the ability to set a property on an arbitrary object
13
- 'defineProperty' in Object && (function() {
14
- try {
15
- var a = {};
16
- Object.defineProperty(a, 'test', {value:42});
17
- return true;
18
- } catch(e) {
19
- return false
20
- }
21
- }())
22
- );
23
-
24
- if (detect) return
25
-
26
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
27
- (function (nativeDefineProperty) {
28
-
29
- var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
30
- var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
31
- var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
32
-
33
- Object.defineProperty = function defineProperty(object, property, descriptor) {
34
-
35
- // Where native support exists, assume it
36
- if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
37
- return nativeDefineProperty(object, property, descriptor);
38
- }
7
+ (function(undefined) {
8
+
9
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
10
+ var detect = (
11
+ // In IE8, defineProperty could only act on DOM elements, so full support
12
+ // for the feature requires the ability to set a property on an arbitrary object
13
+ 'defineProperty' in Object && (function() {
14
+ try {
15
+ var a = {};
16
+ Object.defineProperty(a, 'test', {value:42});
17
+ return true;
18
+ } catch(e) {
19
+ return false
20
+ }
21
+ }())
22
+ );
23
+
24
+ if (detect) return
25
+
26
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
27
+ (function (nativeDefineProperty) {
28
+
29
+ var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
30
+ var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
31
+ var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
32
+
33
+ Object.defineProperty = function defineProperty(object, property, descriptor) {
34
+
35
+ // Where native support exists, assume it
36
+ if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
37
+ return nativeDefineProperty(object, property, descriptor);
38
+ }
39
39
 
40
- if (object === null || !(object instanceof Object || typeof object === 'object')) {
41
- throw new TypeError('Object.defineProperty called on non-object');
42
- }
40
+ if (object === null || !(object instanceof Object || typeof object === 'object')) {
41
+ throw new TypeError('Object.defineProperty called on non-object');
42
+ }
43
43
 
44
- if (!(descriptor instanceof Object)) {
45
- throw new TypeError('Property description must be an object');
46
- }
44
+ if (!(descriptor instanceof Object)) {
45
+ throw new TypeError('Property description must be an object');
46
+ }
47
47
 
48
- var propertyString = String(property);
49
- var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
50
- var getterType = 'get' in descriptor && typeof descriptor.get;
51
- var setterType = 'set' in descriptor && typeof descriptor.set;
48
+ var propertyString = String(property);
49
+ var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
50
+ var getterType = 'get' in descriptor && typeof descriptor.get;
51
+ var setterType = 'set' in descriptor && typeof descriptor.set;
52
52
 
53
- // handle descriptor.get
54
- if (getterType) {
55
- if (getterType !== 'function') {
56
- throw new TypeError('Getter must be a function');
57
- }
58
- if (!supportsAccessors) {
59
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
60
- }
61
- if (hasValueOrWritable) {
62
- throw new TypeError(ERR_VALUE_ACCESSORS);
53
+ // handle descriptor.get
54
+ if (getterType) {
55
+ if (getterType !== 'function') {
56
+ throw new TypeError('Getter must be a function');
57
+ }
58
+ if (!supportsAccessors) {
59
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
60
+ }
61
+ if (hasValueOrWritable) {
62
+ throw new TypeError(ERR_VALUE_ACCESSORS);
63
+ }
64
+ Object.__defineGetter__.call(object, propertyString, descriptor.get);
65
+ } else {
66
+ object[propertyString] = descriptor.value;
63
67
  }
64
- Object.__defineGetter__.call(object, propertyString, descriptor.get);
65
- } else {
66
- object[propertyString] = descriptor.value;
67
- }
68
68
 
69
- // handle descriptor.set
70
- if (setterType) {
71
- if (setterType !== 'function') {
72
- throw new TypeError('Setter must be a function');
73
- }
74
- if (!supportsAccessors) {
75
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
69
+ // handle descriptor.set
70
+ if (setterType) {
71
+ if (setterType !== 'function') {
72
+ throw new TypeError('Setter must be a function');
73
+ }
74
+ if (!supportsAccessors) {
75
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
76
+ }
77
+ if (hasValueOrWritable) {
78
+ throw new TypeError(ERR_VALUE_ACCESSORS);
79
+ }
80
+ Object.__defineSetter__.call(object, propertyString, descriptor.set);
76
81
  }
77
- if (hasValueOrWritable) {
78
- throw new TypeError(ERR_VALUE_ACCESSORS);
82
+
83
+ // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
84
+ if ('value' in descriptor) {
85
+ object[propertyString] = descriptor.value;
79
86
  }
80
- Object.__defineSetter__.call(object, propertyString, descriptor.set);
81
- }
82
87
 
83
- // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
84
- if ('value' in descriptor) {
85
- object[propertyString] = descriptor.value;
86
- }
88
+ return object;
89
+ };
90
+ }(Object.defineProperty));
91
+ })
92
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
93
+
94
+ (function(undefined) {
95
+
96
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
97
+ var detect = (
98
+ 'DOMTokenList' in this && (function (x) {
99
+ return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
100
+ })(document.createElement('x'))
101
+ );
102
+
103
+ if (detect) return
104
+
105
+ // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
106
+ (function (global) {
107
+ var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
108
+
109
+ if (
110
+ !nativeImpl ||
111
+ (
112
+ !!document.createElementNS &&
113
+ !!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
114
+ !(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
115
+ )
116
+ ) {
117
+ global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
118
+ var dpSupport = true;
119
+ var defineGetter = function (object, name, fn, configurable) {
120
+ if (Object.defineProperty)
121
+ Object.defineProperty(object, name, {
122
+ configurable: false === dpSupport ? true : !!configurable,
123
+ get: fn
124
+ });
125
+
126
+ else object.__defineGetter__(name, fn);
127
+ };
128
+
129
+ /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
130
+ try {
131
+ defineGetter({}, "support");
132
+ }
133
+ catch (e) {
134
+ dpSupport = false;
135
+ }
136
+
137
+
138
+ var _DOMTokenList = function (el, prop) {
139
+ var that = this;
140
+ var tokens = [];
141
+ var tokenMap = {};
142
+ var length = 0;
143
+ var maxLength = 0;
144
+ var addIndexGetter = function (i) {
145
+ defineGetter(that, i, function () {
146
+ preop();
147
+ return tokens[i];
148
+ }, false);
149
+
150
+ };
151
+ var reindex = function () {
152
+
153
+ /** Define getter functions for array-like access to the tokenList's contents. */
154
+ if (length >= maxLength)
155
+ for (; maxLength < length; ++maxLength) {
156
+ addIndexGetter(maxLength);
157
+ }
158
+ };
159
+
160
+ /** Helper function called at the start of each class method. Internal use only. */
161
+ var preop = function () {
162
+ var error;
163
+ var i;
164
+ var args = arguments;
165
+ var rSpace = /\s+/;
166
+
167
+ /** Validate the token/s passed to an instance method, if any. */
168
+ if (args.length)
169
+ for (i = 0; i < args.length; ++i)
170
+ if (rSpace.test(args[i])) {
171
+ error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
172
+ error.code = 5;
173
+ error.name = "InvalidCharacterError";
174
+ throw error;
175
+ }
176
+
177
+
178
+ /** Split the new value apart by whitespace*/
179
+ if (typeof el[prop] === "object") {
180
+ tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
181
+ } else {
182
+ tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
183
+ }
184
+
185
+ /** Avoid treating blank strings as single-item token lists */
186
+ if ("" === tokens[0]) tokens = [];
187
+
188
+ /** Repopulate the internal token lists */
189
+ tokenMap = {};
190
+ for (i = 0; i < tokens.length; ++i)
191
+ tokenMap[tokens[i]] = true;
192
+ length = tokens.length;
193
+ reindex();
194
+ };
195
+
196
+ /** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
197
+ preop();
198
+
199
+ /** Return the number of tokens in the underlying string. Read-only. */
200
+ defineGetter(that, "length", function () {
201
+ preop();
202
+ return length;
203
+ });
204
+
205
+ /** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
206
+ that.toLocaleString =
207
+ that.toString = function () {
208
+ preop();
209
+ return tokens.join(" ");
210
+ };
211
+
212
+ that.item = function (idx) {
213
+ preop();
214
+ return tokens[idx];
215
+ };
216
+
217
+ that.contains = function (token) {
218
+ preop();
219
+ return !!tokenMap[token];
220
+ };
221
+
222
+ that.add = function () {
223
+ preop.apply(that, args = arguments);
224
+
225
+ for (var args, token, i = 0, l = args.length; i < l; ++i) {
226
+ token = args[i];
227
+ if (!tokenMap[token]) {
228
+ tokens.push(token);
229
+ tokenMap[token] = true;
230
+ }
231
+ }
232
+
233
+ /** Update the targeted attribute of the attached element if the token list's changed. */
234
+ if (length !== tokens.length) {
235
+ length = tokens.length >>> 0;
236
+ if (typeof el[prop] === "object") {
237
+ el[prop].baseVal = tokens.join(" ");
238
+ } else {
239
+ el[prop] = tokens.join(" ");
240
+ }
241
+ reindex();
242
+ }
243
+ };
244
+
245
+ that.remove = function () {
246
+ preop.apply(that, args = arguments);
247
+
248
+ /** Build a hash of token names to compare against when recollecting our token list. */
249
+ for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
250
+ ignore[args[i]] = true;
251
+ delete tokenMap[args[i]];
252
+ }
253
+
254
+ /** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
255
+ for (i = 0; i < tokens.length; ++i)
256
+ if (!ignore[tokens[i]]) t.push(tokens[i]);
257
+
258
+ tokens = t;
259
+ length = t.length >>> 0;
260
+
261
+ /** Update the targeted attribute of the attached element. */
262
+ if (typeof el[prop] === "object") {
263
+ el[prop].baseVal = tokens.join(" ");
264
+ } else {
265
+ el[prop] = tokens.join(" ");
266
+ }
267
+ reindex();
268
+ };
269
+
270
+ that.toggle = function (token, force) {
271
+ preop.apply(that, [token]);
272
+
273
+ /** Token state's being forced. */
274
+ if (undefined !== force) {
275
+ if (force) {
276
+ that.add(token);
277
+ return true;
278
+ } else {
279
+ that.remove(token);
280
+ return false;
281
+ }
282
+ }
283
+
284
+ /** Token already exists in tokenList. Remove it, and return FALSE. */
285
+ if (tokenMap[token]) {
286
+ that.remove(token);
287
+ return false;
288
+ }
289
+
290
+ /** Otherwise, add the token and return TRUE. */
291
+ that.add(token);
292
+ return true;
293
+ };
294
+
295
+ return that;
296
+ };
297
+
298
+ return _DOMTokenList;
299
+ }());
300
+ }
301
+
302
+ // Add second argument to native DOMTokenList.toggle() if necessary
303
+ (function () {
304
+ var e = document.createElement('span');
305
+ if (!('classList' in e)) return;
306
+ e.classList.toggle('x', false);
307
+ if (!e.classList.contains('x')) return;
308
+ e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
309
+ var force = arguments[1];
310
+ if (force === undefined) {
311
+ var add = !this.contains(token);
312
+ this[add ? 'add' : 'remove'](token);
313
+ return add;
314
+ }
315
+ force = !!force;
316
+ this[force ? 'add' : 'remove'](token);
317
+ return force;
318
+ };
319
+ }());
320
+
321
+ // Add multiple arguments to native DOMTokenList.add() if necessary
322
+ (function () {
323
+ var e = document.createElement('span');
324
+ if (!('classList' in e)) return;
325
+ e.classList.add('a', 'b');
326
+ if (e.classList.contains('b')) return;
327
+ var native = e.classList.constructor.prototype.add;
328
+ e.classList.constructor.prototype.add = function () {
329
+ var args = arguments;
330
+ var l = arguments.length;
331
+ for (var i = 0; i < l; i++) {
332
+ native.call(this, args[i]);
333
+ }
334
+ };
335
+ }());
336
+
337
+ // Add multiple arguments to native DOMTokenList.remove() if necessary
338
+ (function () {
339
+ var e = document.createElement('span');
340
+ if (!('classList' in e)) return;
341
+ e.classList.add('a');
342
+ e.classList.add('b');
343
+ e.classList.remove('a', 'b');
344
+ if (!e.classList.contains('b')) return;
345
+ var native = e.classList.constructor.prototype.remove;
346
+ e.classList.constructor.prototype.remove = function () {
347
+ var args = arguments;
348
+ var l = arguments.length;
349
+ for (var i = 0; i < l; i++) {
350
+ native.call(this, args[i]);
351
+ }
352
+ };
353
+ }());
354
+
355
+ }(this));
356
+
357
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
358
+
359
+ (function(undefined) {
360
+
361
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
362
+ var detect = ("Document" in this);
363
+
364
+ if (detect) return
365
+
366
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
367
+ if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
368
+
369
+ if (this.HTMLDocument) { // IE8
370
+
371
+ // HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
372
+ this.Document = this.HTMLDocument;
87
373
 
88
- return object;
89
- };
90
- }(Object.defineProperty));
91
- })
92
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
93
-
94
- (function(undefined) {
95
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
96
- var detect = 'bind' in Function.prototype;
97
-
98
- if (detect) return
99
-
100
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
101
- Object.defineProperty(Function.prototype, 'bind', {
102
- value: function bind(that) { // .length is 1
103
- // add necessary es5-shim utilities
104
- var $Array = Array;
105
- var $Object = Object;
106
- var ObjectPrototype = $Object.prototype;
107
- var ArrayPrototype = $Array.prototype;
108
- var Empty = function Empty() {};
109
- var to_string = ObjectPrototype.toString;
110
- var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
111
- var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, tryFunctionObject = function tryFunctionObject(value) { try { fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]'; isCallable = function isCallable(value) { if (typeof value !== 'function') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
112
- var array_slice = ArrayPrototype.slice;
113
- var array_concat = ArrayPrototype.concat;
114
- var array_push = ArrayPrototype.push;
115
- var max = Math.max;
116
- // /add necessary es5-shim utilities
117
-
118
- // 1. Let Target be the this value.
119
- var target = this;
120
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
121
- if (!isCallable(target)) {
122
- throw new TypeError('Function.prototype.bind called on incompatible ' + target);
123
- }
124
- // 3. Let A be a new (possibly empty) internal list of all of the
125
- // argument values provided after thisArg (arg1, arg2 etc), in order.
126
- // XXX slicedArgs will stand in for "A" if used
127
- var args = array_slice.call(arguments, 1); // for normal call
128
- // 4. Let F be a new native ECMAScript object.
129
- // 11. Set the [[Prototype]] internal property of F to the standard
130
- // built-in Function prototype object as specified in 15.3.3.1.
131
- // 12. Set the [[Call]] internal property of F as described in
132
- // 15.3.4.5.1.
133
- // 13. Set the [[Construct]] internal property of F as described in
134
- // 15.3.4.5.2.
135
- // 14. Set the [[HasInstance]] internal property of F as described in
136
- // 15.3.4.5.3.
137
- var bound;
138
- var binder = function () {
139
-
140
- if (this instanceof bound) {
141
- // 15.3.4.5.2 [[Construct]]
142
- // When the [[Construct]] internal method of a function object,
143
- // F that was created using the bind function is called with a
144
- // list of arguments ExtraArgs, the following steps are taken:
145
- // 1. Let target be the value of F's [[TargetFunction]]
146
- // internal property.
147
- // 2. If target has no [[Construct]] internal method, a
148
- // TypeError exception is thrown.
149
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
150
- // property.
151
- // 4. Let args be a new list containing the same values as the
152
- // list boundArgs in the same order followed by the same
153
- // values as the list ExtraArgs in the same order.
154
- // 5. Return the result of calling the [[Construct]] internal
155
- // method of target providing args as the arguments.
156
-
157
- var result = target.apply(
158
- this,
159
- array_concat.call(args, array_slice.call(arguments))
160
- );
161
- if ($Object(result) === result) {
162
- return result;
163
- }
164
- return this;
165
-
166
- } else {
167
- // 15.3.4.5.1 [[Call]]
168
- // When the [[Call]] internal method of a function object, F,
169
- // which was created using the bind function is called with a
170
- // this value and a list of arguments ExtraArgs, the following
171
- // steps are taken:
172
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
173
- // property.
174
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
175
- // property.
176
- // 3. Let target be the value of F's [[TargetFunction]] internal
177
- // property.
178
- // 4. Let args be a new list containing the same values as the
179
- // list boundArgs in the same order followed by the same
180
- // values as the list ExtraArgs in the same order.
181
- // 5. Return the result of calling the [[Call]] internal method
182
- // of target providing boundThis as the this value and
183
- // providing args as the arguments.
184
-
185
- // equiv: target.call(this, ...boundArgs, ...args)
186
- return target.apply(
187
- that,
188
- array_concat.call(args, array_slice.call(arguments))
189
- );
190
-
191
- }
192
-
193
- };
194
-
195
- // 15. If the [[Class]] internal property of Target is "Function", then
196
- // a. Let L be the length property of Target minus the length of A.
197
- // b. Set the length own property of F to either 0 or L, whichever is
198
- // larger.
199
- // 16. Else set the length own property of F to 0.
200
-
201
- var boundLength = max(0, target.length - args.length);
202
-
203
- // 17. Set the attributes of the length own property of F to the values
204
- // specified in 15.3.5.1.
205
- var boundArgs = [];
206
- for (var i = 0; i < boundLength; i++) {
207
- array_push.call(boundArgs, '$' + i);
208
- }
209
-
210
- // XXX Build a dynamic function with desired amount of arguments is the only
211
- // way to set the length property of a function.
212
- // In environments where Content Security Policies enabled (Chrome extensions,
213
- // for ex.) all use of eval or Function costructor throws an exception.
214
- // However in all of these environments Function.prototype.bind exists
215
- // and so this code will never be executed.
216
- bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
217
-
218
- if (target.prototype) {
219
- Empty.prototype = target.prototype;
220
- bound.prototype = new Empty();
221
- // Clean up dangling references.
222
- Empty.prototype = null;
223
- }
224
-
225
- // TODO
226
- // 18. Set the [[Extensible]] internal property of F to true.
227
-
228
- // TODO
229
- // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
230
- // 20. Call the [[DefineOwnProperty]] internal method of F with
231
- // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
232
- // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
233
- // false.
234
- // 21. Call the [[DefineOwnProperty]] internal method of F with
235
- // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
236
- // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
237
- // and false.
238
-
239
- // TODO
240
- // NOTE Function objects created using Function.prototype.bind do not
241
- // have a prototype property or the [[Code]], [[FormalParameters]], and
242
- // [[Scope]] internal properties.
243
- // XXX can't delete prototype in pure-js.
244
-
245
- // 22. Return F.
246
- return bound;
247
- }
248
- });
249
- })
250
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
251
-
252
- (function(undefined) {
253
-
254
- // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
255
- var detect = (
256
- 'DOMTokenList' in this && (function (x) {
257
- return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
258
- })(document.createElement('x'))
259
- );
260
-
261
- if (detect) return
262
-
263
- // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
264
- (function (global) {
265
- var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
266
-
267
- if (
268
- !nativeImpl ||
269
- (
270
- !!document.createElementNS &&
271
- !!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
272
- !(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
273
- )
274
- ) {
275
- global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
276
- var dpSupport = true;
277
- var defineGetter = function (object, name, fn, configurable) {
278
- if (Object.defineProperty)
279
- Object.defineProperty(object, name, {
280
- configurable: false === dpSupport ? true : !!configurable,
281
- get: fn
282
- });
283
-
284
- else object.__defineGetter__(name, fn);
285
- };
286
-
287
- /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
288
- try {
289
- defineGetter({}, "support");
290
- }
291
- catch (e) {
292
- dpSupport = false;
293
- }
294
-
295
-
296
- var _DOMTokenList = function (el, prop) {
297
- var that = this;
298
- var tokens = [];
299
- var tokenMap = {};
300
- var length = 0;
301
- var maxLength = 0;
302
- var addIndexGetter = function (i) {
303
- defineGetter(that, i, function () {
304
- preop();
305
- return tokens[i];
306
- }, false);
307
-
308
- };
309
- var reindex = function () {
310
-
311
- /** Define getter functions for array-like access to the tokenList's contents. */
312
- if (length >= maxLength)
313
- for (; maxLength < length; ++maxLength) {
314
- addIndexGetter(maxLength);
315
- }
316
- };
317
-
318
- /** Helper function called at the start of each class method. Internal use only. */
319
- var preop = function () {
320
- var error;
321
- var i;
322
- var args = arguments;
323
- var rSpace = /\s+/;
324
-
325
- /** Validate the token/s passed to an instance method, if any. */
326
- if (args.length)
327
- for (i = 0; i < args.length; ++i)
328
- if (rSpace.test(args[i])) {
329
- error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
330
- error.code = 5;
331
- error.name = "InvalidCharacterError";
332
- throw error;
333
- }
334
-
335
-
336
- /** Split the new value apart by whitespace*/
337
- if (typeof el[prop] === "object") {
338
- tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
339
- } else {
340
- tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
341
- }
342
-
343
- /** Avoid treating blank strings as single-item token lists */
344
- if ("" === tokens[0]) tokens = [];
345
-
346
- /** Repopulate the internal token lists */
347
- tokenMap = {};
348
- for (i = 0; i < tokens.length; ++i)
349
- tokenMap[tokens[i]] = true;
350
- length = tokens.length;
351
- reindex();
352
- };
353
-
354
- /** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
355
- preop();
356
-
357
- /** Return the number of tokens in the underlying string. Read-only. */
358
- defineGetter(that, "length", function () {
359
- preop();
360
- return length;
361
- });
362
-
363
- /** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
364
- that.toLocaleString =
365
- that.toString = function () {
366
- preop();
367
- return tokens.join(" ");
368
- };
369
-
370
- that.item = function (idx) {
371
- preop();
372
- return tokens[idx];
373
- };
374
-
375
- that.contains = function (token) {
376
- preop();
377
- return !!tokenMap[token];
378
- };
379
-
380
- that.add = function () {
381
- preop.apply(that, args = arguments);
382
-
383
- for (var args, token, i = 0, l = args.length; i < l; ++i) {
384
- token = args[i];
385
- if (!tokenMap[token]) {
386
- tokens.push(token);
387
- tokenMap[token] = true;
388
- }
389
- }
390
-
391
- /** Update the targeted attribute of the attached element if the token list's changed. */
392
- if (length !== tokens.length) {
393
- length = tokens.length >>> 0;
394
- if (typeof el[prop] === "object") {
395
- el[prop].baseVal = tokens.join(" ");
396
- } else {
397
- el[prop] = tokens.join(" ");
398
- }
399
- reindex();
400
- }
401
- };
402
-
403
- that.remove = function () {
404
- preop.apply(that, args = arguments);
405
-
406
- /** Build a hash of token names to compare against when recollecting our token list. */
407
- for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
408
- ignore[args[i]] = true;
409
- delete tokenMap[args[i]];
410
- }
411
-
412
- /** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
413
- for (i = 0; i < tokens.length; ++i)
414
- if (!ignore[tokens[i]]) t.push(tokens[i]);
415
-
416
- tokens = t;
417
- length = t.length >>> 0;
418
-
419
- /** Update the targeted attribute of the attached element. */
420
- if (typeof el[prop] === "object") {
421
- el[prop].baseVal = tokens.join(" ");
422
- } else {
423
- el[prop] = tokens.join(" ");
424
- }
425
- reindex();
426
- };
427
-
428
- that.toggle = function (token, force) {
429
- preop.apply(that, [token]);
430
-
431
- /** Token state's being forced. */
432
- if (undefined !== force) {
433
- if (force) {
434
- that.add(token);
435
- return true;
436
- } else {
437
- that.remove(token);
438
- return false;
439
- }
440
- }
441
-
442
- /** Token already exists in tokenList. Remove it, and return FALSE. */
443
- if (tokenMap[token]) {
444
- that.remove(token);
445
- return false;
446
- }
447
-
448
- /** Otherwise, add the token and return TRUE. */
449
- that.add(token);
450
- return true;
451
- };
452
-
453
- return that;
454
- };
455
-
456
- return _DOMTokenList;
457
- }());
458
- }
459
-
460
- // Add second argument to native DOMTokenList.toggle() if necessary
461
- (function () {
462
- var e = document.createElement('span');
463
- if (!('classList' in e)) return;
464
- e.classList.toggle('x', false);
465
- if (!e.classList.contains('x')) return;
466
- e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
467
- var force = arguments[1];
468
- if (force === undefined) {
469
- var add = !this.contains(token);
470
- this[add ? 'add' : 'remove'](token);
471
- return add;
472
- }
473
- force = !!force;
474
- this[force ? 'add' : 'remove'](token);
475
- return force;
476
- };
477
- }());
478
-
479
- // Add multiple arguments to native DOMTokenList.add() if necessary
480
- (function () {
481
- var e = document.createElement('span');
482
- if (!('classList' in e)) return;
483
- e.classList.add('a', 'b');
484
- if (e.classList.contains('b')) return;
485
- var native = e.classList.constructor.prototype.add;
486
- e.classList.constructor.prototype.add = function () {
487
- var args = arguments;
488
- var l = arguments.length;
489
- for (var i = 0; i < l; i++) {
490
- native.call(this, args[i]);
491
- }
492
- };
493
- }());
494
-
495
- // Add multiple arguments to native DOMTokenList.remove() if necessary
496
- (function () {
497
- var e = document.createElement('span');
498
- if (!('classList' in e)) return;
499
- e.classList.add('a');
500
- e.classList.add('b');
501
- e.classList.remove('a', 'b');
502
- if (!e.classList.contains('b')) return;
503
- var native = e.classList.constructor.prototype.remove;
504
- e.classList.constructor.prototype.remove = function () {
505
- var args = arguments;
506
- var l = arguments.length;
507
- for (var i = 0; i < l; i++) {
508
- native.call(this, args[i]);
509
- }
510
- };
511
- }());
512
-
513
- }(this));
514
-
515
- }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
516
-
517
- (function(undefined) {
518
-
519
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
520
- var detect = ("Document" in this);
521
-
522
- if (detect) return
523
-
524
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
525
- if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
526
-
527
- if (this.HTMLDocument) { // IE8
528
-
529
- // HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
530
- this.Document = this.HTMLDocument;
531
-
532
- } else {
533
-
534
- // Create an empty function to act as the missing constructor for the document object, attach the document object as its prototype. The function needs to be anonymous else it is hoisted and causes the feature detect to prematurely pass, preventing the assignments below being made.
535
- this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
536
- this.Document.prototype = document;
374
+ } else {
375
+
376
+ // Create an empty function to act as the missing constructor for the document object, attach the document object as its prototype. The function needs to be anonymous else it is hoisted and causes the feature detect to prematurely pass, preventing the assignments below being made.
377
+ this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
378
+ this.Document.prototype = document;
379
+ }
537
380
  }
538
- }
539
381
 
540
382
 
541
- })
542
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
383
+ })
384
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
543
385
 
544
- (function(undefined) {
386
+ (function(undefined) {
545
387
 
546
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
547
- var detect = ('Element' in this && 'HTMLElement' in this);
388
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
389
+ var detect = ('Element' in this && 'HTMLElement' in this);
548
390
 
549
- if (detect) return
391
+ if (detect) return
550
392
 
551
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
552
- (function () {
393
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
394
+ (function () {
553
395
 
554
- // IE8
555
- if (window.Element && !window.HTMLElement) {
556
- window.HTMLElement = window.Element;
557
- return;
558
- }
396
+ // IE8
397
+ if (window.Element && !window.HTMLElement) {
398
+ window.HTMLElement = window.Element;
399
+ return;
400
+ }
559
401
 
560
- // create Element constructor
561
- window.Element = window.HTMLElement = new Function('return function Element() {}')();
402
+ // create Element constructor
403
+ window.Element = window.HTMLElement = new Function('return function Element() {}')();
562
404
 
563
- // generate sandboxed iframe
564
- var vbody = document.appendChild(document.createElement('body'));
565
- var frame = vbody.appendChild(document.createElement('iframe'));
405
+ // generate sandboxed iframe
406
+ var vbody = document.appendChild(document.createElement('body'));
407
+ var frame = vbody.appendChild(document.createElement('iframe'));
566
408
 
567
- // use sandboxed iframe to replicate Element functionality
568
- var frameDocument = frame.contentWindow.document;
569
- var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
570
- var cache = {};
409
+ // use sandboxed iframe to replicate Element functionality
410
+ var frameDocument = frame.contentWindow.document;
411
+ var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
412
+ var cache = {};
571
413
 
572
- // polyfill Element.prototype on an element
573
- var shiv = function (element, deep) {
574
- var
575
- childNodes = element.childNodes || [],
576
- index = -1,
577
- key, value, childNode;
414
+ // polyfill Element.prototype on an element
415
+ var shiv = function (element, deep) {
416
+ var
417
+ childNodes = element.childNodes || [],
418
+ index = -1,
419
+ key, value, childNode;
578
420
 
579
- if (element.nodeType === 1 && element.constructor !== Element) {
580
- element.constructor = Element;
421
+ if (element.nodeType === 1 && element.constructor !== Element) {
422
+ element.constructor = Element;
581
423
 
582
- for (key in cache) {
583
- value = cache[key];
584
- element[key] = value;
424
+ for (key in cache) {
425
+ value = cache[key];
426
+ element[key] = value;
427
+ }
585
428
  }
586
- }
587
429
 
588
- while (childNode = deep && childNodes[++index]) {
589
- shiv(childNode, deep);
590
- }
430
+ while (childNode = deep && childNodes[++index]) {
431
+ shiv(childNode, deep);
432
+ }
591
433
 
592
- return element;
593
- };
434
+ return element;
435
+ };
594
436
 
595
- var elements = document.getElementsByTagName('*');
596
- var nativeCreateElement = document.createElement;
597
- var interval;
598
- var loopLimit = 100;
599
-
600
- prototype.attachEvent('onpropertychange', function (event) {
601
- var
602
- propertyName = event.propertyName,
603
- nonValue = !cache.hasOwnProperty(propertyName),
604
- newValue = prototype[propertyName],
605
- oldValue = cache[propertyName],
606
- index = -1,
607
- element;
608
-
609
- while (element = elements[++index]) {
610
- if (element.nodeType === 1) {
611
- if (nonValue || element[propertyName] === oldValue) {
612
- element[propertyName] = newValue;
437
+ var elements = document.getElementsByTagName('*');
438
+ var nativeCreateElement = document.createElement;
439
+ var interval;
440
+ var loopLimit = 100;
441
+
442
+ prototype.attachEvent('onpropertychange', function (event) {
443
+ var
444
+ propertyName = event.propertyName,
445
+ nonValue = !cache.hasOwnProperty(propertyName),
446
+ newValue = prototype[propertyName],
447
+ oldValue = cache[propertyName],
448
+ index = -1,
449
+ element;
450
+
451
+ while (element = elements[++index]) {
452
+ if (element.nodeType === 1) {
453
+ if (nonValue || element[propertyName] === oldValue) {
454
+ element[propertyName] = newValue;
455
+ }
613
456
  }
614
457
  }
615
- }
616
458
 
617
- cache[propertyName] = newValue;
618
- });
459
+ cache[propertyName] = newValue;
460
+ });
619
461
 
620
- prototype.constructor = Element;
462
+ prototype.constructor = Element;
621
463
 
622
- if (!prototype.hasAttribute) {
623
- // <Element>.hasAttribute
624
- prototype.hasAttribute = function hasAttribute(name) {
625
- return this.getAttribute(name) !== null;
626
- };
627
- }
464
+ if (!prototype.hasAttribute) {
465
+ // <Element>.hasAttribute
466
+ prototype.hasAttribute = function hasAttribute(name) {
467
+ return this.getAttribute(name) !== null;
468
+ };
469
+ }
628
470
 
629
- // Apply Element prototype to the pre-existing DOM as soon as the body element appears.
630
- function bodyCheck() {
631
- if (!(loopLimit--)) clearTimeout(interval);
632
- if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
633
- shiv(document, true);
634
- if (interval && document.body.prototype) clearTimeout(interval);
635
- return (!!document.body.prototype);
471
+ // Apply Element prototype to the pre-existing DOM as soon as the body element appears.
472
+ function bodyCheck() {
473
+ if (!(loopLimit--)) clearTimeout(interval);
474
+ if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
475
+ shiv(document, true);
476
+ if (interval && document.body.prototype) clearTimeout(interval);
477
+ return (!!document.body.prototype);
478
+ }
479
+ return false;
480
+ }
481
+ if (!bodyCheck()) {
482
+ document.onreadystatechange = bodyCheck;
483
+ interval = setInterval(bodyCheck, 25);
636
484
  }
637
- return false;
638
- }
639
- if (!bodyCheck()) {
640
- document.onreadystatechange = bodyCheck;
641
- interval = setInterval(bodyCheck, 25);
642
- }
643
485
 
644
- // Apply to any new elements created after load
645
- document.createElement = function createElement(nodeName) {
646
- var element = nativeCreateElement(String(nodeName).toLowerCase());
647
- return shiv(element);
648
- };
486
+ // Apply to any new elements created after load
487
+ document.createElement = function createElement(nodeName) {
488
+ var element = nativeCreateElement(String(nodeName).toLowerCase());
489
+ return shiv(element);
490
+ };
649
491
 
650
- // remove sandboxed iframe
651
- document.removeChild(vbody);
652
- }());
653
-
654
- })
655
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
656
-
657
- (function(undefined) {
658
-
659
- // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
660
- var detect = (
661
- 'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
662
- var e = document.createElement('span');
663
- e.classList.add('a', 'b');
664
- return e.classList.contains('b');
665
- }())
666
- );
667
-
668
- if (detect) return
669
-
670
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.classList&flags=always
671
- (function (global) {
672
- var dpSupport = true;
673
- var defineGetter = function (object, name, fn, configurable) {
674
- if (Object.defineProperty)
675
- Object.defineProperty(object, name, {
676
- configurable: false === dpSupport ? true : !!configurable,
677
- get: fn
678
- });
679
-
680
- else object.__defineGetter__(name, fn);
681
- };
682
- /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
683
- try {
684
- defineGetter({}, "support");
685
- }
686
- catch (e) {
687
- dpSupport = false;
688
- }
689
- /** Polyfills a property with a DOMTokenList */
690
- var addProp = function (o, name, attr) {
691
-
692
- defineGetter(o.prototype, name, function () {
693
- var tokenList;
694
-
695
- var THIS = this,
696
-
697
- /** Prevent this from firing twice for some reason. What the hell, IE. */
698
- gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
699
- if(THIS[gibberishProperty]) return tokenList;
700
- THIS[gibberishProperty] = true;
701
-
702
- /**
703
- * IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
704
- *
705
- * What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
706
- * that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
707
- * element instead, this would conflict with element types which use indexed properties (such as forms and
708
- * select lists).
709
- */
710
- if (false === dpSupport) {
711
-
712
- var visage;
713
- var mirror = addProp.mirror || document.createElement("div");
714
- var reflections = mirror.childNodes;
715
- var l = reflections.length;
716
-
717
- for (var i = 0; i < l; ++i)
718
- if (reflections[i]._R === THIS) {
719
- visage = reflections[i];
720
- break;
721
- }
722
-
723
- /** Couldn't find an element's reflection inside the mirror. Materialise one. */
724
- visage || (visage = mirror.appendChild(document.createElement("div")));
725
-
726
- tokenList = DOMTokenList.call(visage, THIS, attr);
727
- } else tokenList = new DOMTokenList(THIS, attr);
728
-
729
- defineGetter(THIS, name, function () {
730
- return tokenList;
731
- });
732
- delete THIS[gibberishProperty];
733
-
734
- return tokenList;
735
- }, true);
736
- };
737
-
738
- addProp(global.Element, "classList", "className");
739
- addProp(global.HTMLElement, "classList", "className");
740
- addProp(global.HTMLLinkElement, "relList", "rel");
741
- addProp(global.HTMLAnchorElement, "relList", "rel");
742
- addProp(global.HTMLAreaElement, "relList", "rel");
743
- }(this));
744
-
745
- }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
746
-
747
- (function(undefined) {
748
-
749
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
750
- var detect = ('Window' in this);
751
-
752
- if (detect) return
753
-
754
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Window&flags=always
755
- if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
756
- (function (global) {
757
- if (global.constructor) {
758
- global.Window = global.constructor;
759
- } else {
760
- (global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
761
- }
762
- }(this));
763
- }
764
-
765
- })
766
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
767
-
768
- (function(undefined) {
769
-
770
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
771
- var detect = (
772
- (function(global) {
773
-
774
- if (!('Event' in global)) return false;
775
- if (typeof global.Event === 'function') return true;
776
-
777
- try {
778
-
779
- // In IE 9-11, the Event object exists but cannot be instantiated
780
- new Event('click');
781
- return true;
782
- } catch(e) {
783
- return false;
784
- }
785
- }(this))
786
- );
787
-
788
- if (detect) return
789
-
790
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Event&flags=always
791
- (function () {
792
- var unlistenableWindowEvents = {
793
- click: 1,
794
- dblclick: 1,
795
- keyup: 1,
796
- keypress: 1,
797
- keydown: 1,
798
- mousedown: 1,
799
- mouseup: 1,
800
- mousemove: 1,
801
- mouseover: 1,
802
- mouseenter: 1,
803
- mouseleave: 1,
804
- mouseout: 1,
805
- storage: 1,
806
- storagecommit: 1,
807
- textinput: 1
808
- };
492
+ // remove sandboxed iframe
493
+ document.removeChild(vbody);
494
+ }());
495
+
496
+ })
497
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
498
+
499
+ (function(undefined) {
500
+
501
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
502
+ var detect = (
503
+ 'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
504
+ var e = document.createElement('span');
505
+ e.classList.add('a', 'b');
506
+ return e.classList.contains('b');
507
+ }())
508
+ );
509
+
510
+ if (detect) return
511
+
512
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.classList&flags=always
513
+ (function (global) {
514
+ var dpSupport = true;
515
+ var defineGetter = function (object, name, fn, configurable) {
516
+ if (Object.defineProperty)
517
+ Object.defineProperty(object, name, {
518
+ configurable: false === dpSupport ? true : !!configurable,
519
+ get: fn
520
+ });
521
+
522
+ else object.__defineGetter__(name, fn);
523
+ };
524
+ /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
525
+ try {
526
+ defineGetter({}, "support");
527
+ }
528
+ catch (e) {
529
+ dpSupport = false;
530
+ }
531
+ /** Polyfills a property with a DOMTokenList */
532
+ var addProp = function (o, name, attr) {
533
+
534
+ defineGetter(o.prototype, name, function () {
535
+ var tokenList;
536
+
537
+ var THIS = this,
538
+
539
+ /** Prevent this from firing twice for some reason. What the hell, IE. */
540
+ gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
541
+ if(THIS[gibberishProperty]) return tokenList;
542
+ THIS[gibberishProperty] = true;
543
+
544
+ /**
545
+ * IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
546
+ *
547
+ * What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
548
+ * that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
549
+ * element instead, this would conflict with element types which use indexed properties (such as forms and
550
+ * select lists).
551
+ */
552
+ if (false === dpSupport) {
553
+
554
+ var visage;
555
+ var mirror = addProp.mirror || document.createElement("div");
556
+ var reflections = mirror.childNodes;
557
+ var l = reflections.length;
558
+
559
+ for (var i = 0; i < l; ++i)
560
+ if (reflections[i]._R === THIS) {
561
+ visage = reflections[i];
562
+ break;
563
+ }
564
+
565
+ /** Couldn't find an element's reflection inside the mirror. Materialise one. */
566
+ visage || (visage = mirror.appendChild(document.createElement("div")));
567
+
568
+ tokenList = DOMTokenList.call(visage, THIS, attr);
569
+ } else tokenList = new DOMTokenList(THIS, attr);
570
+
571
+ defineGetter(THIS, name, function () {
572
+ return tokenList;
573
+ });
574
+ delete THIS[gibberishProperty];
575
+
576
+ return tokenList;
577
+ }, true);
578
+ };
579
+
580
+ addProp(global.Element, "classList", "className");
581
+ addProp(global.HTMLElement, "classList", "className");
582
+ addProp(global.HTMLLinkElement, "relList", "rel");
583
+ addProp(global.HTMLAnchorElement, "relList", "rel");
584
+ addProp(global.HTMLAreaElement, "relList", "rel");
585
+ }(this));
586
+
587
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
588
+
589
+ (function(undefined) {
590
+
591
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
592
+ var detect = ('Window' in this);
593
+
594
+ if (detect) return
595
+
596
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Window&flags=always
597
+ if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
598
+ (function (global) {
599
+ if (global.constructor) {
600
+ global.Window = global.constructor;
601
+ } else {
602
+ (global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
603
+ }
604
+ }(this));
605
+ }
809
606
 
810
- // This polyfill depends on availability of `document` so will not run in a worker
811
- // However, we asssume there are no browsers with worker support that lack proper
812
- // support for `Event` within the worker
813
- if (typeof document === 'undefined' || typeof window === 'undefined') return;
607
+ })
608
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
609
+
610
+ (function(undefined) {
611
+
612
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
613
+ var detect = (
614
+ (function(global) {
615
+
616
+ if (!('Event' in global)) return false;
617
+ if (typeof global.Event === 'function') return true;
618
+
619
+ try {
620
+
621
+ // In IE 9-11, the Event object exists but cannot be instantiated
622
+ new Event('click');
623
+ return true;
624
+ } catch(e) {
625
+ return false;
626
+ }
627
+ }(this))
628
+ );
629
+
630
+ if (detect) return
631
+
632
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Event&flags=always
633
+ (function () {
634
+ var unlistenableWindowEvents = {
635
+ click: 1,
636
+ dblclick: 1,
637
+ keyup: 1,
638
+ keypress: 1,
639
+ keydown: 1,
640
+ mousedown: 1,
641
+ mouseup: 1,
642
+ mousemove: 1,
643
+ mouseover: 1,
644
+ mouseenter: 1,
645
+ mouseleave: 1,
646
+ mouseout: 1,
647
+ storage: 1,
648
+ storagecommit: 1,
649
+ textinput: 1
650
+ };
651
+
652
+ // This polyfill depends on availability of `document` so will not run in a worker
653
+ // However, we asssume there are no browsers with worker support that lack proper
654
+ // support for `Event` within the worker
655
+ if (typeof document === 'undefined' || typeof window === 'undefined') return;
814
656
 
815
- function indexOf(array, element) {
816
- var
817
- index = -1,
818
- length = array.length;
657
+ function indexOf(array, element) {
658
+ var
659
+ index = -1,
660
+ length = array.length;
819
661
 
820
- while (++index < length) {
821
- if (index in array && array[index] === element) {
822
- return index;
662
+ while (++index < length) {
663
+ if (index in array && array[index] === element) {
664
+ return index;
665
+ }
823
666
  }
667
+
668
+ return -1;
824
669
  }
825
670
 
826
- return -1;
827
- }
671
+ var existingProto = (window.Event && window.Event.prototype) || null;
672
+ window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
673
+ if (!type) {
674
+ throw new Error('Not enough arguments');
675
+ }
828
676
 
829
- var existingProto = (window.Event && window.Event.prototype) || null;
830
- window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
831
- if (!type) {
832
- throw new Error('Not enough arguments');
833
- }
677
+ var event;
678
+ // Shortcut if browser supports createEvent
679
+ if ('createEvent' in document) {
680
+ event = document.createEvent('Event');
681
+ var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
682
+ var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
683
+
684
+ event.initEvent(type, bubbles, cancelable);
685
+
686
+ return event;
687
+ }
834
688
 
835
- var event;
836
- // Shortcut if browser supports createEvent
837
- if ('createEvent' in document) {
838
- event = document.createEvent('Event');
839
- var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
840
- var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
689
+ event = document.createEventObject();
841
690
 
842
- event.initEvent(type, bubbles, cancelable);
691
+ event.type = type;
692
+ event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
693
+ event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
843
694
 
844
695
  return event;
696
+ };
697
+ if (existingProto) {
698
+ Object.defineProperty(window.Event, 'prototype', {
699
+ configurable: false,
700
+ enumerable: false,
701
+ writable: true,
702
+ value: existingProto
703
+ });
845
704
  }
846
705
 
847
- event = document.createEventObject();
706
+ if (!('createEvent' in document)) {
707
+ window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
708
+ var
709
+ element = this,
710
+ type = arguments[0],
711
+ listener = arguments[1];
848
712
 
849
- event.type = type;
850
- event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
851
- event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
713
+ if (element === window && type in unlistenableWindowEvents) {
714
+ throw new Error('In IE8 the event: ' + type + ' is not available on the window object. Please see https://github.com/Financial-Times/polyfill-service/issues/317 for more information.');
715
+ }
852
716
 
853
- return event;
854
- };
855
- if (existingProto) {
856
- Object.defineProperty(window.Event, 'prototype', {
857
- configurable: false,
858
- enumerable: false,
859
- writable: true,
860
- value: existingProto
861
- });
862
- }
717
+ if (!element._events) {
718
+ element._events = {};
719
+ }
863
720
 
864
- if (!('createEvent' in document)) {
865
- window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
866
- var
867
- element = this,
868
- type = arguments[0],
869
- listener = arguments[1];
721
+ if (!element._events[type]) {
722
+ element._events[type] = function (event) {
723
+ var
724
+ list = element._events[event.type].list,
725
+ events = list.slice(),
726
+ index = -1,
727
+ length = events.length,
728
+ eventElement;
729
+
730
+ event.preventDefault = function preventDefault() {
731
+ if (event.cancelable !== false) {
732
+ event.returnValue = false;
733
+ }
734
+ };
870
735
 
871
- if (element === window && type in unlistenableWindowEvents) {
872
- throw new Error('In IE8 the event: ' + type + ' is not available on the window object. Please see https://github.com/Financial-Times/polyfill-service/issues/317 for more information.');
873
- }
736
+ event.stopPropagation = function stopPropagation() {
737
+ event.cancelBubble = true;
738
+ };
874
739
 
875
- if (!element._events) {
876
- element._events = {};
877
- }
740
+ event.stopImmediatePropagation = function stopImmediatePropagation() {
741
+ event.cancelBubble = true;
742
+ event.cancelImmediate = true;
743
+ };
878
744
 
879
- if (!element._events[type]) {
880
- element._events[type] = function (event) {
881
- var
882
- list = element._events[event.type].list,
883
- events = list.slice(),
884
- index = -1,
885
- length = events.length,
886
- eventElement;
887
-
888
- event.preventDefault = function preventDefault() {
889
- if (event.cancelable !== false) {
890
- event.returnValue = false;
745
+ event.currentTarget = element;
746
+ event.relatedTarget = event.fromElement || null;
747
+ event.target = event.target || event.srcElement || element;
748
+ event.timeStamp = new Date().getTime();
749
+
750
+ if (event.clientX) {
751
+ event.pageX = event.clientX + document.documentElement.scrollLeft;
752
+ event.pageY = event.clientY + document.documentElement.scrollTop;
891
753
  }
892
- };
893
754
 
894
- event.stopPropagation = function stopPropagation() {
895
- event.cancelBubble = true;
896
- };
755
+ while (++index < length && !event.cancelImmediate) {
756
+ if (index in events) {
757
+ eventElement = events[index];
897
758
 
898
- event.stopImmediatePropagation = function stopImmediatePropagation() {
899
- event.cancelBubble = true;
900
- event.cancelImmediate = true;
759
+ if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
760
+ eventElement.call(element, event);
761
+ }
762
+ }
763
+ }
901
764
  };
902
765
 
903
- event.currentTarget = element;
904
- event.relatedTarget = event.fromElement || null;
905
- event.target = event.target || event.srcElement || element;
906
- event.timeStamp = new Date().getTime();
766
+ element._events[type].list = [];
907
767
 
908
- if (event.clientX) {
909
- event.pageX = event.clientX + document.documentElement.scrollLeft;
910
- event.pageY = event.clientY + document.documentElement.scrollTop;
768
+ if (element.attachEvent) {
769
+ element.attachEvent('on' + type, element._events[type]);
911
770
  }
771
+ }
912
772
 
913
- while (++index < length && !event.cancelImmediate) {
914
- if (index in events) {
915
- eventElement = events[index];
773
+ element._events[type].list.push(listener);
774
+ };
916
775
 
917
- if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
918
- eventElement.call(element, event);
776
+ window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
777
+ var
778
+ element = this,
779
+ type = arguments[0],
780
+ listener = arguments[1],
781
+ index;
782
+
783
+ if (element._events && element._events[type] && element._events[type].list) {
784
+ index = indexOf(element._events[type].list, listener);
785
+
786
+ if (index !== -1) {
787
+ element._events[type].list.splice(index, 1);
788
+
789
+ if (!element._events[type].list.length) {
790
+ if (element.detachEvent) {
791
+ element.detachEvent('on' + type, element._events[type]);
919
792
  }
793
+ delete element._events[type];
920
794
  }
921
795
  }
922
- };
796
+ }
797
+ };
923
798
 
924
- element._events[type].list = [];
799
+ window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
800
+ if (!arguments.length) {
801
+ throw new Error('Not enough arguments');
802
+ }
925
803
 
926
- if (element.attachEvent) {
927
- element.attachEvent('on' + type, element._events[type]);
804
+ if (!event || typeof event.type !== 'string') {
805
+ throw new Error('DOM Events Exception 0');
928
806
  }
929
- }
930
807
 
931
- element._events[type].list.push(listener);
932
- };
808
+ var element = this, type = event.type;
933
809
 
934
- window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
935
- var
936
- element = this,
937
- type = arguments[0],
938
- listener = arguments[1],
939
- index;
810
+ try {
811
+ if (!event.bubbles) {
812
+ event.cancelBubble = true;
940
813
 
941
- if (element._events && element._events[type] && element._events[type].list) {
942
- index = indexOf(element._events[type].list, listener);
814
+ var cancelBubbleEvent = function (event) {
815
+ event.cancelBubble = true;
943
816
 
944
- if (index !== -1) {
945
- element._events[type].list.splice(index, 1);
817
+ (element || window).detachEvent('on' + type, cancelBubbleEvent);
818
+ };
946
819
 
947
- if (!element._events[type].list.length) {
948
- if (element.detachEvent) {
949
- element.detachEvent('on' + type, element._events[type]);
950
- }
951
- delete element._events[type];
820
+ this.attachEvent('on' + type, cancelBubbleEvent);
952
821
  }
953
- }
954
- }
955
- };
956
822
 
957
- window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
958
- if (!arguments.length) {
959
- throw new Error('Not enough arguments');
960
- }
823
+ this.fireEvent('on' + type, event);
824
+ } catch (error) {
825
+ event.target = element;
961
826
 
962
- if (!event || typeof event.type !== 'string') {
963
- throw new Error('DOM Events Exception 0');
964
- }
827
+ do {
828
+ event.currentTarget = element;
965
829
 
966
- var element = this, type = event.type;
830
+ if ('_events' in element && typeof element._events[type] === 'function') {
831
+ element._events[type].call(element, event);
832
+ }
967
833
 
968
- try {
969
- if (!event.bubbles) {
970
- event.cancelBubble = true;
834
+ if (typeof element['on' + type] === 'function') {
835
+ element['on' + type].call(element, event);
836
+ }
971
837
 
972
- var cancelBubbleEvent = function (event) {
973
- event.cancelBubble = true;
838
+ element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
839
+ } while (element && !event.cancelBubble);
840
+ }
974
841
 
975
- (element || window).detachEvent('on' + type, cancelBubbleEvent);
976
- };
842
+ return true;
843
+ };
977
844
 
978
- this.attachEvent('on' + type, cancelBubbleEvent);
845
+ // Add the DOMContentLoaded Event
846
+ document.attachEvent('onreadystatechange', function() {
847
+ if (document.readyState === 'complete') {
848
+ document.dispatchEvent(new Event('DOMContentLoaded', {
849
+ bubbles: true
850
+ }));
979
851
  }
852
+ });
853
+ }
854
+ }());
855
+
856
+ })
857
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
858
+
859
+ (function(undefined) {
860
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
861
+ var detect = 'bind' in Function.prototype;
862
+
863
+ if (detect) return
864
+
865
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
866
+ Object.defineProperty(Function.prototype, 'bind', {
867
+ value: function bind(that) { // .length is 1
868
+ // add necessary es5-shim utilities
869
+ var $Array = Array;
870
+ var $Object = Object;
871
+ var ObjectPrototype = $Object.prototype;
872
+ var ArrayPrototype = $Array.prototype;
873
+ var Empty = function Empty() {};
874
+ var to_string = ObjectPrototype.toString;
875
+ var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
876
+ var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, tryFunctionObject = function tryFunctionObject(value) { try { fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]'; isCallable = function isCallable(value) { if (typeof value !== 'function') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
877
+ var array_slice = ArrayPrototype.slice;
878
+ var array_concat = ArrayPrototype.concat;
879
+ var array_push = ArrayPrototype.push;
880
+ var max = Math.max;
881
+ // /add necessary es5-shim utilities
882
+
883
+ // 1. Let Target be the this value.
884
+ var target = this;
885
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
886
+ if (!isCallable(target)) {
887
+ throw new TypeError('Function.prototype.bind called on incompatible ' + target);
888
+ }
889
+ // 3. Let A be a new (possibly empty) internal list of all of the
890
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
891
+ // XXX slicedArgs will stand in for "A" if used
892
+ var args = array_slice.call(arguments, 1); // for normal call
893
+ // 4. Let F be a new native ECMAScript object.
894
+ // 11. Set the [[Prototype]] internal property of F to the standard
895
+ // built-in Function prototype object as specified in 15.3.3.1.
896
+ // 12. Set the [[Call]] internal property of F as described in
897
+ // 15.3.4.5.1.
898
+ // 13. Set the [[Construct]] internal property of F as described in
899
+ // 15.3.4.5.2.
900
+ // 14. Set the [[HasInstance]] internal property of F as described in
901
+ // 15.3.4.5.3.
902
+ var bound;
903
+ var binder = function () {
904
+
905
+ if (this instanceof bound) {
906
+ // 15.3.4.5.2 [[Construct]]
907
+ // When the [[Construct]] internal method of a function object,
908
+ // F that was created using the bind function is called with a
909
+ // list of arguments ExtraArgs, the following steps are taken:
910
+ // 1. Let target be the value of F's [[TargetFunction]]
911
+ // internal property.
912
+ // 2. If target has no [[Construct]] internal method, a
913
+ // TypeError exception is thrown.
914
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
915
+ // property.
916
+ // 4. Let args be a new list containing the same values as the
917
+ // list boundArgs in the same order followed by the same
918
+ // values as the list ExtraArgs in the same order.
919
+ // 5. Return the result of calling the [[Construct]] internal
920
+ // method of target providing args as the arguments.
921
+
922
+ var result = target.apply(
923
+ this,
924
+ array_concat.call(args, array_slice.call(arguments))
925
+ );
926
+ if ($Object(result) === result) {
927
+ return result;
928
+ }
929
+ return this;
930
+
931
+ } else {
932
+ // 15.3.4.5.1 [[Call]]
933
+ // When the [[Call]] internal method of a function object, F,
934
+ // which was created using the bind function is called with a
935
+ // this value and a list of arguments ExtraArgs, the following
936
+ // steps are taken:
937
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
938
+ // property.
939
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
940
+ // property.
941
+ // 3. Let target be the value of F's [[TargetFunction]] internal
942
+ // property.
943
+ // 4. Let args be a new list containing the same values as the
944
+ // list boundArgs in the same order followed by the same
945
+ // values as the list ExtraArgs in the same order.
946
+ // 5. Return the result of calling the [[Call]] internal method
947
+ // of target providing boundThis as the this value and
948
+ // providing args as the arguments.
949
+
950
+ // equiv: target.call(this, ...boundArgs, ...args)
951
+ return target.apply(
952
+ that,
953
+ array_concat.call(args, array_slice.call(arguments))
954
+ );
955
+
956
+ }
957
+
958
+ };
959
+
960
+ // 15. If the [[Class]] internal property of Target is "Function", then
961
+ // a. Let L be the length property of Target minus the length of A.
962
+ // b. Set the length own property of F to either 0 or L, whichever is
963
+ // larger.
964
+ // 16. Else set the length own property of F to 0.
965
+
966
+ var boundLength = max(0, target.length - args.length);
967
+
968
+ // 17. Set the attributes of the length own property of F to the values
969
+ // specified in 15.3.5.1.
970
+ var boundArgs = [];
971
+ for (var i = 0; i < boundLength; i++) {
972
+ array_push.call(boundArgs, '$' + i);
973
+ }
974
+
975
+ // XXX Build a dynamic function with desired amount of arguments is the only
976
+ // way to set the length property of a function.
977
+ // In environments where Content Security Policies enabled (Chrome extensions,
978
+ // for ex.) all use of eval or Function costructor throws an exception.
979
+ // However in all of these environments Function.prototype.bind exists
980
+ // and so this code will never be executed.
981
+ bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
982
+
983
+ if (target.prototype) {
984
+ Empty.prototype = target.prototype;
985
+ bound.prototype = new Empty();
986
+ // Clean up dangling references.
987
+ Empty.prototype = null;
988
+ }
989
+
990
+ // TODO
991
+ // 18. Set the [[Extensible]] internal property of F to true.
992
+
993
+ // TODO
994
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
995
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
996
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
997
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
998
+ // false.
999
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
1000
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
1001
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
1002
+ // and false.
1003
+
1004
+ // TODO
1005
+ // NOTE Function objects created using Function.prototype.bind do not
1006
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
1007
+ // [[Scope]] internal properties.
1008
+ // XXX can't delete prototype in pure-js.
1009
+
1010
+ // 22. Return F.
1011
+ return bound;
1012
+ }
1013
+ });
1014
+ })
1015
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1016
+
1017
+ /* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */
1018
+
1019
+ /**
1020
+ * Skip link component
1021
+ *
1022
+ * @class
1023
+ * @param {HTMLElement} $module - HTML element to use for skip link
1024
+ */
1025
+ function SkipLink ($module) {
1026
+ this.$module = $module;
1027
+ this.$linkedElement = null;
1028
+ this.linkedElementListener = false;
1029
+ }
980
1030
 
981
- this.fireEvent('on' + type, event);
982
- } catch (error) {
983
- event.target = element;
1031
+ /**
1032
+ * Initialise component
1033
+ */
1034
+ SkipLink.prototype.init = function () {
1035
+ // Check for module
1036
+ if (!this.$module) {
1037
+ return
1038
+ }
1039
+
1040
+ // Check for linked element
1041
+ this.$linkedElement = this.getLinkedElement();
1042
+ if (!this.$linkedElement) {
1043
+ return
1044
+ }
1045
+
1046
+ this.$module.addEventListener('click', this.focusLinkedElement.bind(this));
1047
+ };
984
1048
 
985
- do {
986
- event.currentTarget = element;
1049
+ /**
1050
+ * Get linked element
1051
+ *
1052
+ * @returns {HTMLElement} $linkedElement - DOM element linked to from the skip link
1053
+ */
1054
+ SkipLink.prototype.getLinkedElement = function () {
1055
+ var linkedElementId = this.getFragmentFromUrl();
987
1056
 
988
- if ('_events' in element && typeof element._events[type] === 'function') {
989
- element._events[type].call(element, event);
990
- }
1057
+ if (!linkedElementId) {
1058
+ return false
1059
+ }
991
1060
 
992
- if (typeof element['on' + type] === 'function') {
993
- element['on' + type].call(element, event);
994
- }
1061
+ return document.getElementById(linkedElementId)
1062
+ };
995
1063
 
996
- element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
997
- } while (element && !event.cancelBubble);
998
- }
1064
+ /**
1065
+ * Focus the linked element
1066
+ *
1067
+ * Set tabindex and helper CSS class. Set listener to remove them on blur.
1068
+ */
1069
+ SkipLink.prototype.focusLinkedElement = function () {
1070
+ var $linkedElement = this.$linkedElement;
1071
+
1072
+ if (!$linkedElement.getAttribute('tabindex')) {
1073
+ // Set the element tabindex to -1 so it can be focused with JavaScript.
1074
+ $linkedElement.setAttribute('tabindex', '-1');
1075
+ $linkedElement.classList.add('govuk-skip-link-focused-element');
1076
+
1077
+ // Add listener for blur on the focused element (unless the listener has previously been added)
1078
+ if (!this.linkedElementListener) {
1079
+ this.$linkedElement.addEventListener('blur', this.removeFocusProperties.bind(this));
1080
+ this.linkedElementListener = true;
1081
+ }
1082
+ }
1083
+ $linkedElement.focus();
1084
+ };
999
1085
 
1000
- return true;
1001
- };
1086
+ /**
1087
+ * Remove the tabindex that makes the linked element focusable because the element only needs to be
1088
+ * focusable until it has received programmatic focus and a screen reader has announced it.
1089
+ *
1090
+ * Remove the CSS class that removes the native focus styles.
1091
+ */
1092
+ SkipLink.prototype.removeFocusProperties = function () {
1093
+ this.$linkedElement.removeAttribute('tabindex');
1094
+ this.$linkedElement.classList.remove('govuk-skip-link-focused-element');
1095
+ };
1002
1096
 
1003
- // Add the DOMContentLoaded Event
1004
- document.attachEvent('onreadystatechange', function() {
1005
- if (document.readyState === 'complete') {
1006
- document.dispatchEvent(new Event('DOMContentLoaded', {
1007
- bubbles: true
1008
- }));
1009
- }
1010
- });
1011
- }
1012
- }());
1013
-
1014
- })
1015
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1016
-
1017
- /**
1018
- * Skip link component
1019
- *
1020
- * @class
1021
- * @param {HTMLElement} $module - HTML element to use for skip link
1022
- */
1023
- function SkipLink ($module) {
1024
- this.$module = $module;
1025
- this.$linkedElement = null;
1026
- this.linkedElementListener = false;
1027
- }
1028
-
1029
- /**
1030
- * Initialise the component
1031
- */
1032
- SkipLink.prototype.init = function () {
1033
- // Check for module
1034
- if (!this.$module) {
1035
- return
1036
- }
1037
-
1038
- // Check for linked element
1039
- this.$linkedElement = this.getLinkedElement();
1040
- if (!this.$linkedElement) {
1041
- return
1042
- }
1043
-
1044
- this.$module.addEventListener('click', this.focusLinkedElement.bind(this));
1045
- };
1046
-
1047
- /**
1048
- * Get linked element
1049
- *
1050
- * @returns {HTMLElement} $linkedElement - DOM element linked to from the skip link
1051
- */
1052
- SkipLink.prototype.getLinkedElement = function () {
1053
- var linkedElementId = this.getFragmentFromUrl();
1054
-
1055
- if (!linkedElementId) {
1056
- return false
1057
- }
1058
-
1059
- return document.getElementById(linkedElementId)
1060
- };
1061
-
1062
- /**
1063
- * Focus the linked element
1064
- *
1065
- * Set tabindex and helper CSS class. Set listener to remove them on blur.
1066
- */
1067
- SkipLink.prototype.focusLinkedElement = function () {
1068
- var $linkedElement = this.$linkedElement;
1069
-
1070
- if (!$linkedElement.getAttribute('tabindex')) {
1071
- // Set the element tabindex to -1 so it can be focused with JavaScript.
1072
- $linkedElement.setAttribute('tabindex', '-1');
1073
- $linkedElement.classList.add('govuk-skip-link-focused-element');
1074
-
1075
- // Add listener for blur on the focused element (unless the listener has previously been added)
1076
- if (!this.linkedElementListener) {
1077
- this.$linkedElement.addEventListener('blur', this.removeFocusProperties.bind(this));
1078
- this.linkedElementListener = true;
1079
- }
1080
- }
1081
- $linkedElement.focus();
1082
- };
1083
-
1084
- /**
1085
- * Remove the tabindex that makes the linked element focusable because the element only needs to be
1086
- * focusable until it has received programmatic focus and a screen reader has announced it.
1087
- *
1088
- * Remove the CSS class that removes the native focus styles.
1089
- */
1090
- SkipLink.prototype.removeFocusProperties = function () {
1091
- this.$linkedElement.removeAttribute('tabindex');
1092
- this.$linkedElement.classList.remove('govuk-skip-link-focused-element');
1093
- };
1094
-
1095
- /**
1096
- * Get fragment from URL
1097
- *
1098
- * Extract the fragment (everything after the hash symbol) from a URL, but not including
1099
- * the symbol.
1100
- *
1101
- * @returns {string} Fragment from URL, without the hash symbol
1102
- */
1103
- SkipLink.prototype.getFragmentFromUrl = function () {
1104
- // Bail if the anchor link doesn't have a hash
1105
- if (!this.$module.hash) {
1106
- return false
1107
- }
1108
-
1109
- return this.$module.hash.split('#').pop()
1110
- };
1111
-
1112
- return SkipLink;
1097
+ /**
1098
+ * Get fragment from URL
1099
+ *
1100
+ * Extract the fragment (everything after the hash symbol) from a URL, but not including
1101
+ * the symbol.
1102
+ *
1103
+ * @returns {string} Fragment from URL, without the hash symbol
1104
+ */
1105
+ SkipLink.prototype.getFragmentFromUrl = function () {
1106
+ // Bail if the anchor link doesn't have a hash
1107
+ if (!this.$module.hash) {
1108
+ return false
1109
+ }
1110
+
1111
+ return this.$module.hash.split('#').pop()
1112
+ };
1113
+
1114
+ return SkipLink;
1113
1115
 
1114
1116
  })));
1117
+ //# sourceMappingURL=skip-link.js.map