govuk_publishing_components 34.7.0 → 34.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +3 -10
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-form-tracker.js +113 -0
  4. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +2 -11
  5. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js +15 -1
  6. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js +20 -29
  7. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +1 -0
  8. data/app/models/govuk_publishing_components/component_doc.rb +14 -0
  9. data/app/models/govuk_publishing_components/component_wrapper_helper_options.rb +14 -0
  10. data/app/views/govuk_publishing_components/component_guide/show.html.erb +21 -6
  11. data/app/views/govuk_publishing_components/components/_action_link.html.erb +5 -2
  12. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +6 -2
  13. data/app/views/govuk_publishing_components/components/_details.html.erb +3 -1
  14. data/app/views/govuk_publishing_components/components/docs/action_link.yml +1 -0
  15. data/app/views/govuk_publishing_components/components/docs/breadcrumbs.yml +1 -0
  16. data/app/views/govuk_publishing_components/components/docs/details.yml +17 -0
  17. data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +78 -0
  18. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +0 -7
  19. data/lib/govuk_publishing_components/version.rb +1 -1
  20. data/lib/govuk_publishing_components.rb +1 -0
  21. data/node_modules/govuk-frontend/govuk/all.js +4029 -3792
  22. data/node_modules/govuk-frontend/govuk/all.js.map +1 -0
  23. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +52 -51
  24. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js.map +1 -0
  25. data/node_modules/govuk-frontend/govuk/common/index.js +153 -145
  26. data/node_modules/govuk-frontend/govuk/common/index.js.map +1 -0
  27. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +324 -321
  28. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js.map +1 -0
  29. data/node_modules/govuk-frontend/govuk/common.js +154 -146
  30. data/node_modules/govuk-frontend/govuk/common.js.map +1 -0
  31. data/node_modules/govuk-frontend/govuk/components/_all.scss +1 -1
  32. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +23 -4
  33. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +2059 -1654
  34. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js.map +1 -0
  35. data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +11 -11
  36. data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +1 -1
  37. data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +19 -19
  38. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +21 -10
  39. data/node_modules/govuk-frontend/govuk/components/button/button.js +927 -917
  40. data/node_modules/govuk-frontend/govuk/components/button/button.js.map +1 -0
  41. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +2050 -2040
  42. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js.map +1 -0
  43. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +1155 -1147
  44. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js.map +1 -0
  45. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +23 -23
  46. data/node_modules/govuk-frontend/govuk/components/cookie-banner/template.njk +1 -1
  47. data/node_modules/govuk-frontend/govuk/components/details/details.js +800 -799
  48. data/node_modules/govuk-frontend/govuk/components/details/details.js.map +1 -0
  49. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +1058 -1045
  50. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js.map +1 -0
  51. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +6 -0
  52. data/node_modules/govuk-frontend/govuk/components/header/header.js +646 -998
  53. data/node_modules/govuk-frontend/govuk/components/header/header.js.map +1 -0
  54. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +760 -752
  55. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js.map +1 -0
  56. data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +61 -0
  57. data/node_modules/govuk-frontend/govuk/components/pagination/template.njk +1 -1
  58. data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +1 -1
  59. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +1110 -1107
  60. data/node_modules/govuk-frontend/govuk/components/radios/radios.js.map +1 -0
  61. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1017 -1014
  62. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js.map +1 -0
  63. data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +107 -0
  64. data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +318 -23
  65. data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +110 -0
  66. data/node_modules/govuk-frontend/govuk/components/summary-list/template.njk +72 -28
  67. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +1392 -1264
  68. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js.map +1 -0
  69. data/node_modules/govuk-frontend/govuk/i18n.js +363 -364
  70. data/node_modules/govuk-frontend/govuk/i18n.js.map +1 -0
  71. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +5 -5
  72. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +242 -241
  73. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js.map +1 -0
  74. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +13 -12
  75. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js.map +1 -0
  76. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +17 -16
  77. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js.map +1 -0
  78. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +547 -546
  79. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js.map +1 -0
  80. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +37 -36
  81. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js.map +1 -0
  82. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +251 -250
  83. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js.map +1 -0
  84. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +21 -20
  85. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js.map +1 -0
  86. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +198 -197
  87. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js.map +1 -0
  88. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +198 -197
  89. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js.map +1 -0
  90. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +106 -105
  91. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js.map +1 -0
  92. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +400 -399
  93. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js.map +1 -0
  94. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +239 -238
  95. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js.map +1 -0
  96. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +72 -71
  97. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js.map +1 -0
  98. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +14 -13
  99. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js.map +1 -0
  100. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +17 -16
  101. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js.map +1 -0
  102. data/node_modules/govuk-frontend/govuk-esm/all.mjs +2 -2
  103. data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +17 -10
  104. data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +3 -1
  105. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +135 -52
  106. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +11 -9
  107. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +10 -7
  108. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +24 -18
  109. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +23 -16
  110. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +15 -11
  111. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +3 -2
  112. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +3 -4
  113. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +10 -9
  114. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +5 -3
  115. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +165 -38
  116. data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +9 -11
  117. data/node_modules/govuk-frontend/package.json +1 -1
  118. metadata +37 -2
@@ -1,846 +1,847 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
- typeof define === 'function' && define.amd ? define('GOVUKFrontend.Details', factory) :
4
- (global.GOVUKFrontend = global.GOVUKFrontend || {}, global.GOVUKFrontend.Details = factory());
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define('GOVUKFrontend.Details', factory) :
4
+ (global.GOVUKFrontend = global.GOVUKFrontend || {}, global.GOVUKFrontend.Details = 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
- }
39
-
40
- if (object === null || !(object instanceof Object || typeof object === 'object')) {
41
- throw new TypeError('Object.defineProperty called on non-object');
42
- }
43
-
44
- if (!(descriptor instanceof Object)) {
45
- throw new TypeError('Property description must be an object');
46
- }
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;
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);
63
- }
64
- Object.__defineGetter__.call(object, propertyString, descriptor.get);
65
- } else {
66
- object[propertyString] = descriptor.value;
67
- }
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);
76
- }
77
- if (hasValueOrWritable) {
78
- throw new TypeError(ERR_VALUE_ACCESSORS);
79
- }
80
- Object.__defineSetter__.call(object, propertyString, descriptor.set);
81
- }
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;
86
- }
87
-
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;
7
+ /**
8
+ * Common helpers which do not require polyfill.
9
+ *
10
+ * IMPORTANT: If a helper require a polyfill, please isolate it in its own module
11
+ * so that the polyfill can be properly tree-shaken and does not burden
12
+ * the components that do not need that helper
13
+ *
14
+ * @module common/index
15
+ */
16
+
17
+ /**
18
+ * Used to generate a unique string, allows multiple instances of the component
19
+ * without them conflicting with each other.
20
+ * https://stackoverflow.com/a/8809472
21
+ *
22
+ * @returns {string} Unique ID
23
+ */
24
+ function generateUniqueID () {
25
+ var d = new Date().getTime();
26
+ if (typeof window.performance !== 'undefined' && typeof window.performance.now === 'function') {
27
+ d += window.performance.now(); // use high-precision timer if available
28
+ }
29
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
30
+ var r = (d + Math.random() * 16) % 16 | 0;
31
+ d = Math.floor(d / 16);
32
+ return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
33
+ })
34
+ }
35
+
36
+ /**
37
+ * @callback nodeListIterator
38
+ * @param {Element} value - The current node being iterated on
39
+ * @param {number} index - The current index in the iteration
40
+ * @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
41
+ * @returns {void}
42
+ */
43
+
44
+ (function(undefined) {
45
+
46
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
47
+ var detect = ('Window' in this);
97
48
 
98
49
  if (detect) return
99
50
 
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
- }
51
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Window&flags=always
52
+ if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
53
+ (function (global) {
54
+ if (global.constructor) {
55
+ global.Window = global.constructor;
56
+ } else {
57
+ (global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
58
+ }
59
+ }(this));
60
+ }
209
61
 
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
- }
62
+ })
63
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
224
64
 
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 || {});
65
+ (function(undefined) {
66
+
67
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
68
+ var detect = ("Document" in this);
251
69
 
252
- (function(undefined) {
70
+ if (detect) return
71
+
72
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
73
+ if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
253
74
 
254
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
255
- var detect = ('Window' in this);
75
+ if (this.HTMLDocument) { // IE8
256
76
 
257
- if (detect) return
77
+ // HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
78
+ this.Document = this.HTMLDocument;
258
79
 
259
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Window&flags=always
260
- if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
261
- (function (global) {
262
- if (global.constructor) {
263
- global.Window = global.constructor;
264
- } else {
265
- (global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
266
- }
267
- }(this));
268
- }
80
+ } else {
81
+
82
+ // 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.
83
+ this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
84
+ this.Document.prototype = document;
85
+ }
86
+ }
269
87
 
270
- })
271
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
272
88
 
273
- (function(undefined) {
89
+ })
90
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
274
91
 
275
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
276
- var detect = ("Document" in this);
92
+ (function(undefined) {
277
93
 
278
- if (detect) return
94
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
95
+ var detect = ('Element' in this && 'HTMLElement' in this);
279
96
 
280
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
281
- if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
97
+ if (detect) return
282
98
 
283
- if (this.HTMLDocument) { // IE8
99
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
100
+ (function () {
284
101
 
285
- // HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
286
- this.Document = this.HTMLDocument;
102
+ // IE8
103
+ if (window.Element && !window.HTMLElement) {
104
+ window.HTMLElement = window.Element;
105
+ return;
106
+ }
287
107
 
288
- } else {
108
+ // create Element constructor
109
+ window.Element = window.HTMLElement = new Function('return function Element() {}')();
110
+
111
+ // generate sandboxed iframe
112
+ var vbody = document.appendChild(document.createElement('body'));
113
+ var frame = vbody.appendChild(document.createElement('iframe'));
114
+
115
+ // use sandboxed iframe to replicate Element functionality
116
+ var frameDocument = frame.contentWindow.document;
117
+ var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
118
+ var cache = {};
119
+
120
+ // polyfill Element.prototype on an element
121
+ var shiv = function (element, deep) {
122
+ var
123
+ childNodes = element.childNodes || [],
124
+ index = -1,
125
+ key, value, childNode;
126
+
127
+ if (element.nodeType === 1 && element.constructor !== Element) {
128
+ element.constructor = Element;
129
+
130
+ for (key in cache) {
131
+ value = cache[key];
132
+ element[key] = value;
133
+ }
134
+ }
135
+
136
+ while (childNode = deep && childNodes[++index]) {
137
+ shiv(childNode, deep);
138
+ }
139
+
140
+ return element;
141
+ };
142
+
143
+ var elements = document.getElementsByTagName('*');
144
+ var nativeCreateElement = document.createElement;
145
+ var interval;
146
+ var loopLimit = 100;
147
+
148
+ prototype.attachEvent('onpropertychange', function (event) {
149
+ var
150
+ propertyName = event.propertyName,
151
+ nonValue = !cache.hasOwnProperty(propertyName),
152
+ newValue = prototype[propertyName],
153
+ oldValue = cache[propertyName],
154
+ index = -1,
155
+ element;
156
+
157
+ while (element = elements[++index]) {
158
+ if (element.nodeType === 1) {
159
+ if (nonValue || element[propertyName] === oldValue) {
160
+ element[propertyName] = newValue;
161
+ }
162
+ }
163
+ }
164
+
165
+ cache[propertyName] = newValue;
166
+ });
167
+
168
+ prototype.constructor = Element;
169
+
170
+ if (!prototype.hasAttribute) {
171
+ // <Element>.hasAttribute
172
+ prototype.hasAttribute = function hasAttribute(name) {
173
+ return this.getAttribute(name) !== null;
174
+ };
175
+ }
289
176
 
290
- // 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.
291
- this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
292
- this.Document.prototype = document;
293
- }
294
- }
295
-
296
-
297
- })
298
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
299
-
300
- (function(undefined) {
301
-
302
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
303
- var detect = ('Element' in this && 'HTMLElement' in this);
304
-
305
- if (detect) return
306
-
307
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
308
- (function () {
309
-
310
- // IE8
311
- if (window.Element && !window.HTMLElement) {
312
- window.HTMLElement = window.Element;
313
- return;
314
- }
315
-
316
- // create Element constructor
317
- window.Element = window.HTMLElement = new Function('return function Element() {}')();
318
-
319
- // generate sandboxed iframe
320
- var vbody = document.appendChild(document.createElement('body'));
321
- var frame = vbody.appendChild(document.createElement('iframe'));
322
-
323
- // use sandboxed iframe to replicate Element functionality
324
- var frameDocument = frame.contentWindow.document;
325
- var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
326
- var cache = {};
327
-
328
- // polyfill Element.prototype on an element
329
- var shiv = function (element, deep) {
330
- var
331
- childNodes = element.childNodes || [],
332
- index = -1,
333
- key, value, childNode;
334
-
335
- if (element.nodeType === 1 && element.constructor !== Element) {
336
- element.constructor = Element;
337
-
338
- for (key in cache) {
339
- value = cache[key];
340
- element[key] = value;
341
- }
342
- }
343
-
344
- while (childNode = deep && childNodes[++index]) {
345
- shiv(childNode, deep);
346
- }
347
-
348
- return element;
349
- };
350
-
351
- var elements = document.getElementsByTagName('*');
352
- var nativeCreateElement = document.createElement;
353
- var interval;
354
- var loopLimit = 100;
355
-
356
- prototype.attachEvent('onpropertychange', function (event) {
357
- var
358
- propertyName = event.propertyName,
359
- nonValue = !cache.hasOwnProperty(propertyName),
360
- newValue = prototype[propertyName],
361
- oldValue = cache[propertyName],
362
- index = -1,
363
- element;
364
-
365
- while (element = elements[++index]) {
366
- if (element.nodeType === 1) {
367
- if (nonValue || element[propertyName] === oldValue) {
368
- element[propertyName] = newValue;
369
- }
370
- }
371
- }
372
-
373
- cache[propertyName] = newValue;
374
- });
375
-
376
- prototype.constructor = Element;
377
-
378
- if (!prototype.hasAttribute) {
379
- // <Element>.hasAttribute
380
- prototype.hasAttribute = function hasAttribute(name) {
381
- return this.getAttribute(name) !== null;
382
- };
383
- }
384
-
385
- // Apply Element prototype to the pre-existing DOM as soon as the body element appears.
386
- function bodyCheck() {
387
- if (!(loopLimit--)) clearTimeout(interval);
388
- if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
389
- shiv(document, true);
390
- if (interval && document.body.prototype) clearTimeout(interval);
391
- return (!!document.body.prototype);
392
- }
393
- return false;
394
- }
395
- if (!bodyCheck()) {
396
- document.onreadystatechange = bodyCheck;
397
- interval = setInterval(bodyCheck, 25);
398
- }
399
-
400
- // Apply to any new elements created after load
401
- document.createElement = function createElement(nodeName) {
402
- var element = nativeCreateElement(String(nodeName).toLowerCase());
403
- return shiv(element);
404
- };
405
-
406
- // remove sandboxed iframe
407
- document.removeChild(vbody);
408
- }());
409
-
410
- })
411
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
412
-
413
- (function(undefined) {
414
-
415
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
416
- var detect = (
417
- (function(global) {
418
-
419
- if (!('Event' in global)) return false;
420
- if (typeof global.Event === 'function') return true;
421
-
422
- try {
423
-
424
- // In IE 9-11, the Event object exists but cannot be instantiated
425
- new Event('click');
426
- return true;
427
- } catch(e) {
177
+ // Apply Element prototype to the pre-existing DOM as soon as the body element appears.
178
+ function bodyCheck() {
179
+ if (!(loopLimit--)) clearTimeout(interval);
180
+ if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
181
+ shiv(document, true);
182
+ if (interval && document.body.prototype) clearTimeout(interval);
183
+ return (!!document.body.prototype);
184
+ }
428
185
  return false;
429
186
  }
430
- }(this))
431
- );
432
-
433
- if (detect) return
434
-
435
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Event&flags=always
436
- (function () {
437
- var unlistenableWindowEvents = {
438
- click: 1,
439
- dblclick: 1,
440
- keyup: 1,
441
- keypress: 1,
442
- keydown: 1,
443
- mousedown: 1,
444
- mouseup: 1,
445
- mousemove: 1,
446
- mouseover: 1,
447
- mouseenter: 1,
448
- mouseleave: 1,
449
- mouseout: 1,
450
- storage: 1,
451
- storagecommit: 1,
452
- textinput: 1
453
- };
454
-
455
- // This polyfill depends on availability of `document` so will not run in a worker
456
- // However, we asssume there are no browsers with worker support that lack proper
457
- // support for `Event` within the worker
458
- if (typeof document === 'undefined' || typeof window === 'undefined') return;
459
-
460
- function indexOf(array, element) {
461
- var
462
- index = -1,
463
- length = array.length;
464
-
465
- while (++index < length) {
466
- if (index in array && array[index] === element) {
467
- return index;
468
- }
469
- }
470
-
471
- return -1;
472
- }
473
-
474
- var existingProto = (window.Event && window.Event.prototype) || null;
475
- window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
476
- if (!type) {
477
- throw new Error('Not enough arguments');
478
- }
479
-
480
- var event;
481
- // Shortcut if browser supports createEvent
482
- if ('createEvent' in document) {
483
- event = document.createEvent('Event');
484
- var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
485
- var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
486
-
487
- event.initEvent(type, bubbles, cancelable);
488
-
489
- return event;
490
- }
491
-
492
- event = document.createEventObject();
493
-
494
- event.type = type;
495
- event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
496
- event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
497
-
498
- return event;
499
- };
500
- if (existingProto) {
501
- Object.defineProperty(window.Event, 'prototype', {
502
- configurable: false,
503
- enumerable: false,
504
- writable: true,
505
- value: existingProto
506
- });
507
- }
508
-
509
- if (!('createEvent' in document)) {
510
- window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
511
- var
512
- element = this,
513
- type = arguments[0],
514
- listener = arguments[1];
515
-
516
- if (element === window && type in unlistenableWindowEvents) {
517
- 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.');
518
- }
519
-
520
- if (!element._events) {
521
- element._events = {};
522
- }
523
-
524
- if (!element._events[type]) {
525
- element._events[type] = function (event) {
526
- var
527
- list = element._events[event.type].list,
528
- events = list.slice(),
529
- index = -1,
530
- length = events.length,
531
- eventElement;
532
-
533
- event.preventDefault = function preventDefault() {
534
- if (event.cancelable !== false) {
535
- event.returnValue = false;
536
- }
537
- };
538
-
539
- event.stopPropagation = function stopPropagation() {
540
- event.cancelBubble = true;
541
- };
542
-
543
- event.stopImmediatePropagation = function stopImmediatePropagation() {
544
- event.cancelBubble = true;
545
- event.cancelImmediate = true;
546
- };
547
-
548
- event.currentTarget = element;
549
- event.relatedTarget = event.fromElement || null;
550
- event.target = event.target || event.srcElement || element;
551
- event.timeStamp = new Date().getTime();
552
-
553
- if (event.clientX) {
554
- event.pageX = event.clientX + document.documentElement.scrollLeft;
555
- event.pageY = event.clientY + document.documentElement.scrollTop;
556
- }
557
-
558
- while (++index < length && !event.cancelImmediate) {
559
- if (index in events) {
560
- eventElement = events[index];
561
-
562
- if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
563
- eventElement.call(element, event);
564
- }
565
- }
566
- }
567
- };
568
-
569
- element._events[type].list = [];
570
-
571
- if (element.attachEvent) {
572
- element.attachEvent('on' + type, element._events[type]);
573
- }
574
- }
575
-
576
- element._events[type].list.push(listener);
577
- };
578
-
579
- window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
580
- var
581
- element = this,
582
- type = arguments[0],
583
- listener = arguments[1],
584
- index;
585
-
586
- if (element._events && element._events[type] && element._events[type].list) {
587
- index = indexOf(element._events[type].list, listener);
588
-
589
- if (index !== -1) {
590
- element._events[type].list.splice(index, 1);
591
-
592
- if (!element._events[type].list.length) {
593
- if (element.detachEvent) {
594
- element.detachEvent('on' + type, element._events[type]);
595
- }
596
- delete element._events[type];
597
- }
598
- }
599
- }
600
- };
601
-
602
- window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
603
- if (!arguments.length) {
604
- throw new Error('Not enough arguments');
605
- }
606
-
607
- if (!event || typeof event.type !== 'string') {
608
- throw new Error('DOM Events Exception 0');
609
- }
610
-
611
- var element = this, type = event.type;
612
-
613
- try {
614
- if (!event.bubbles) {
615
- event.cancelBubble = true;
616
-
617
- var cancelBubbleEvent = function (event) {
618
- event.cancelBubble = true;
619
-
620
- (element || window).detachEvent('on' + type, cancelBubbleEvent);
621
- };
622
-
623
- this.attachEvent('on' + type, cancelBubbleEvent);
624
- }
625
-
626
- this.fireEvent('on' + type, event);
627
- } catch (error) {
628
- event.target = element;
629
-
630
- do {
631
- event.currentTarget = element;
632
-
633
- if ('_events' in element && typeof element._events[type] === 'function') {
634
- element._events[type].call(element, event);
635
- }
636
-
637
- if (typeof element['on' + type] === 'function') {
638
- element['on' + type].call(element, event);
639
- }
640
-
641
- element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
642
- } while (element && !event.cancelBubble);
643
- }
644
-
645
- return true;
646
- };
647
-
648
- // Add the DOMContentLoaded Event
649
- document.attachEvent('onreadystatechange', function() {
650
- if (document.readyState === 'complete') {
651
- document.dispatchEvent(new Event('DOMContentLoaded', {
652
- bubbles: true
653
- }));
654
- }
655
- });
656
- }
657
- }());
658
-
659
- })
660
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
661
-
662
- /**
663
- * Common helpers which do not require polyfill.
664
- *
665
- * IMPORTANT: If a helper require a polyfill, please isolate it in its own module
666
- * so that the polyfill can be properly tree-shaken and does not burden
667
- * the components that do not need that helper
668
- *
669
- * @module common/index
670
- */
671
-
672
- /**
673
- * Used to generate a unique string, allows multiple instances of the component
674
- * without them conflicting with each other.
675
- * https://stackoverflow.com/a/8809472
676
- *
677
- * @returns {string} Unique ID
678
- */
679
- function generateUniqueID () {
680
- var d = new Date().getTime();
681
- if (typeof window.performance !== 'undefined' && typeof window.performance.now === 'function') {
682
- d += window.performance.now(); // use high-precision timer if available
683
- }
684
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
685
- var r = (d + Math.random() * 16) % 16 | 0;
686
- d = Math.floor(d / 16);
687
- return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
187
+ if (!bodyCheck()) {
188
+ document.onreadystatechange = bodyCheck;
189
+ interval = setInterval(bodyCheck, 25);
190
+ }
191
+
192
+ // Apply to any new elements created after load
193
+ document.createElement = function createElement(nodeName) {
194
+ var element = nativeCreateElement(String(nodeName).toLowerCase());
195
+ return shiv(element);
196
+ };
197
+
198
+ // remove sandboxed iframe
199
+ document.removeChild(vbody);
200
+ }());
201
+
688
202
  })
689
- }
690
-
691
- /**
692
- * @callback nodeListIterator
693
- * @param {Element} value - The current node being iterated on
694
- * @param {number} index - The current index in the iteration
695
- * @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
696
- * @returns {undefined}
697
- */
698
-
699
- /**
700
- * JavaScript 'polyfill' for HTML5's <details> and <summary> elements
701
- * and 'shim' to add accessiblity enhancements for all browsers
702
- *
703
- * http://caniuse.com/#feat=details
704
- */
705
-
706
- var KEY_ENTER = 13;
707
- var KEY_SPACE = 32;
708
-
709
- /**
710
- * Details component
711
- *
712
- * @class
713
- * @param {HTMLElement} $module - HTML element to use for details
714
- */
715
- function Details ($module) {
716
- this.$module = $module;
717
- }
718
-
719
- Details.prototype.init = function () {
720
- if (!this.$module) {
721
- return
722
- }
203
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
204
+
205
+ (function(undefined) {
206
+
207
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
208
+ var detect = (
209
+ // In IE8, defineProperty could only act on DOM elements, so full support
210
+ // for the feature requires the ability to set a property on an arbitrary object
211
+ 'defineProperty' in Object && (function() {
212
+ try {
213
+ var a = {};
214
+ Object.defineProperty(a, 'test', {value:42});
215
+ return true;
216
+ } catch(e) {
217
+ return false
218
+ }
219
+ }())
220
+ );
723
221
 
724
- // If there is native details support, we want to avoid running code to polyfill native behaviour.
725
- var hasNativeDetails = typeof this.$module.open === 'boolean';
222
+ if (detect) return
726
223
 
727
- if (hasNativeDetails) {
728
- return
729
- }
224
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
225
+ (function (nativeDefineProperty) {
226
+
227
+ var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
228
+ var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
229
+ var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
230
+
231
+ Object.defineProperty = function defineProperty(object, property, descriptor) {
232
+
233
+ // Where native support exists, assume it
234
+ if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
235
+ return nativeDefineProperty(object, property, descriptor);
236
+ }
237
+
238
+ if (object === null || !(object instanceof Object || typeof object === 'object')) {
239
+ throw new TypeError('Object.defineProperty called on non-object');
240
+ }
241
+
242
+ if (!(descriptor instanceof Object)) {
243
+ throw new TypeError('Property description must be an object');
244
+ }
245
+
246
+ var propertyString = String(property);
247
+ var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
248
+ var getterType = 'get' in descriptor && typeof descriptor.get;
249
+ var setterType = 'set' in descriptor && typeof descriptor.set;
250
+
251
+ // handle descriptor.get
252
+ if (getterType) {
253
+ if (getterType !== 'function') {
254
+ throw new TypeError('Getter must be a function');
255
+ }
256
+ if (!supportsAccessors) {
257
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
258
+ }
259
+ if (hasValueOrWritable) {
260
+ throw new TypeError(ERR_VALUE_ACCESSORS);
261
+ }
262
+ Object.__defineGetter__.call(object, propertyString, descriptor.get);
263
+ } else {
264
+ object[propertyString] = descriptor.value;
265
+ }
266
+
267
+ // handle descriptor.set
268
+ if (setterType) {
269
+ if (setterType !== 'function') {
270
+ throw new TypeError('Setter must be a function');
271
+ }
272
+ if (!supportsAccessors) {
273
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
274
+ }
275
+ if (hasValueOrWritable) {
276
+ throw new TypeError(ERR_VALUE_ACCESSORS);
277
+ }
278
+ Object.__defineSetter__.call(object, propertyString, descriptor.set);
279
+ }
280
+
281
+ // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
282
+ if ('value' in descriptor) {
283
+ object[propertyString] = descriptor.value;
284
+ }
285
+
286
+ return object;
287
+ };
288
+ }(Object.defineProperty));
289
+ })
290
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
730
291
 
731
- this.polyfillDetails();
732
- };
292
+ (function(undefined) {
733
293
 
734
- Details.prototype.polyfillDetails = function () {
735
- var $module = this.$module;
294
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
295
+ var detect = (
296
+ (function(global) {
736
297
 
737
- // Save shortcuts to the inner summary and content elements
738
- var $summary = this.$summary = $module.getElementsByTagName('summary').item(0);
739
- var $content = this.$content = $module.getElementsByTagName('div').item(0);
298
+ if (!('Event' in global)) return false;
299
+ if (typeof global.Event === 'function') return true;
740
300
 
741
- // If <details> doesn't have a <summary> and a <div> representing the content
742
- // it means the required HTML structure is not met so the script will stop
743
- if (!$summary || !$content) {
744
- return
745
- }
301
+ try {
746
302
 
747
- // If the content doesn't have an ID, assign it one now
748
- // which we'll need for the summary's aria-controls assignment
749
- if (!$content.id) {
750
- $content.id = 'details-content-' + generateUniqueID();
751
- }
303
+ // In IE 9-11, the Event object exists but cannot be instantiated
304
+ new Event('click');
305
+ return true;
306
+ } catch(e) {
307
+ return false;
308
+ }
309
+ }(this))
310
+ );
752
311
 
753
- // Add ARIA role="group" to details
754
- $module.setAttribute('role', 'group');
312
+ if (detect) return
755
313
 
756
- // Add role=button to summary
757
- $summary.setAttribute('role', 'button');
314
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Event&flags=always
315
+ (function () {
316
+ var unlistenableWindowEvents = {
317
+ click: 1,
318
+ dblclick: 1,
319
+ keyup: 1,
320
+ keypress: 1,
321
+ keydown: 1,
322
+ mousedown: 1,
323
+ mouseup: 1,
324
+ mousemove: 1,
325
+ mouseover: 1,
326
+ mouseenter: 1,
327
+ mouseleave: 1,
328
+ mouseout: 1,
329
+ storage: 1,
330
+ storagecommit: 1,
331
+ textinput: 1
332
+ };
333
+
334
+ // This polyfill depends on availability of `document` so will not run in a worker
335
+ // However, we asssume there are no browsers with worker support that lack proper
336
+ // support for `Event` within the worker
337
+ if (typeof document === 'undefined' || typeof window === 'undefined') return;
338
+
339
+ function indexOf(array, element) {
340
+ var
341
+ index = -1,
342
+ length = array.length;
343
+
344
+ while (++index < length) {
345
+ if (index in array && array[index] === element) {
346
+ return index;
347
+ }
348
+ }
349
+
350
+ return -1;
351
+ }
758
352
 
759
- // Add aria-controls
760
- $summary.setAttribute('aria-controls', $content.id);
353
+ var existingProto = (window.Event && window.Event.prototype) || null;
354
+ window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
355
+ if (!type) {
356
+ throw new Error('Not enough arguments');
357
+ }
358
+
359
+ var event;
360
+ // Shortcut if browser supports createEvent
361
+ if ('createEvent' in document) {
362
+ event = document.createEvent('Event');
363
+ var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
364
+ var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
365
+
366
+ event.initEvent(type, bubbles, cancelable);
367
+
368
+ return event;
369
+ }
370
+
371
+ event = document.createEventObject();
372
+
373
+ event.type = type;
374
+ event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
375
+ event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
376
+
377
+ return event;
378
+ };
379
+ if (existingProto) {
380
+ Object.defineProperty(window.Event, 'prototype', {
381
+ configurable: false,
382
+ enumerable: false,
383
+ writable: true,
384
+ value: existingProto
385
+ });
386
+ }
761
387
 
762
- // Set tabIndex so the summary is keyboard accessible for non-native elements
763
- //
764
- // We have to use the camelcase `tabIndex` property as there is a bug in IE6/IE7 when we set the correct attribute lowercase:
765
- // See http://web.archive.org/web/20170120194036/http://www.saliences.com/browserBugs/tabIndex.html for more information.
766
- $summary.tabIndex = 0;
388
+ if (!('createEvent' in document)) {
389
+ window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
390
+ var
391
+ element = this,
392
+ type = arguments[0],
393
+ listener = arguments[1];
394
+
395
+ if (element === window && type in unlistenableWindowEvents) {
396
+ 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.');
397
+ }
398
+
399
+ if (!element._events) {
400
+ element._events = {};
401
+ }
402
+
403
+ if (!element._events[type]) {
404
+ element._events[type] = function (event) {
405
+ var
406
+ list = element._events[event.type].list,
407
+ events = list.slice(),
408
+ index = -1,
409
+ length = events.length,
410
+ eventElement;
411
+
412
+ event.preventDefault = function preventDefault() {
413
+ if (event.cancelable !== false) {
414
+ event.returnValue = false;
415
+ }
416
+ };
417
+
418
+ event.stopPropagation = function stopPropagation() {
419
+ event.cancelBubble = true;
420
+ };
421
+
422
+ event.stopImmediatePropagation = function stopImmediatePropagation() {
423
+ event.cancelBubble = true;
424
+ event.cancelImmediate = true;
425
+ };
426
+
427
+ event.currentTarget = element;
428
+ event.relatedTarget = event.fromElement || null;
429
+ event.target = event.target || event.srcElement || element;
430
+ event.timeStamp = new Date().getTime();
431
+
432
+ if (event.clientX) {
433
+ event.pageX = event.clientX + document.documentElement.scrollLeft;
434
+ event.pageY = event.clientY + document.documentElement.scrollTop;
435
+ }
436
+
437
+ while (++index < length && !event.cancelImmediate) {
438
+ if (index in events) {
439
+ eventElement = events[index];
440
+
441
+ if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
442
+ eventElement.call(element, event);
443
+ }
444
+ }
445
+ }
446
+ };
447
+
448
+ element._events[type].list = [];
449
+
450
+ if (element.attachEvent) {
451
+ element.attachEvent('on' + type, element._events[type]);
452
+ }
453
+ }
454
+
455
+ element._events[type].list.push(listener);
456
+ };
457
+
458
+ window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
459
+ var
460
+ element = this,
461
+ type = arguments[0],
462
+ listener = arguments[1],
463
+ index;
464
+
465
+ if (element._events && element._events[type] && element._events[type].list) {
466
+ index = indexOf(element._events[type].list, listener);
467
+
468
+ if (index !== -1) {
469
+ element._events[type].list.splice(index, 1);
470
+
471
+ if (!element._events[type].list.length) {
472
+ if (element.detachEvent) {
473
+ element.detachEvent('on' + type, element._events[type]);
474
+ }
475
+ delete element._events[type];
476
+ }
477
+ }
478
+ }
479
+ };
480
+
481
+ window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
482
+ if (!arguments.length) {
483
+ throw new Error('Not enough arguments');
484
+ }
485
+
486
+ if (!event || typeof event.type !== 'string') {
487
+ throw new Error('DOM Events Exception 0');
488
+ }
489
+
490
+ var element = this, type = event.type;
491
+
492
+ try {
493
+ if (!event.bubbles) {
494
+ event.cancelBubble = true;
495
+
496
+ var cancelBubbleEvent = function (event) {
497
+ event.cancelBubble = true;
498
+
499
+ (element || window).detachEvent('on' + type, cancelBubbleEvent);
500
+ };
501
+
502
+ this.attachEvent('on' + type, cancelBubbleEvent);
503
+ }
504
+
505
+ this.fireEvent('on' + type, event);
506
+ } catch (error) {
507
+ event.target = element;
508
+
509
+ do {
510
+ event.currentTarget = element;
511
+
512
+ if ('_events' in element && typeof element._events[type] === 'function') {
513
+ element._events[type].call(element, event);
514
+ }
515
+
516
+ if (typeof element['on' + type] === 'function') {
517
+ element['on' + type].call(element, event);
518
+ }
519
+
520
+ element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
521
+ } while (element && !event.cancelBubble);
522
+ }
523
+
524
+ return true;
525
+ };
526
+
527
+ // Add the DOMContentLoaded Event
528
+ document.attachEvent('onreadystatechange', function() {
529
+ if (document.readyState === 'complete') {
530
+ document.dispatchEvent(new Event('DOMContentLoaded', {
531
+ bubbles: true
532
+ }));
533
+ }
534
+ });
535
+ }
536
+ }());
767
537
 
768
- // Detect initial open state
769
- if (this.$module.hasAttribute('open')) {
770
- $summary.setAttribute('aria-expanded', 'true');
771
- } else {
772
- $summary.setAttribute('aria-expanded', 'false');
773
- $content.style.display = 'none';
774
- }
538
+ })
539
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
540
+
541
+ (function(undefined) {
542
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
543
+ var detect = 'bind' in Function.prototype;
544
+
545
+ if (detect) return
546
+
547
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
548
+ Object.defineProperty(Function.prototype, 'bind', {
549
+ value: function bind(that) { // .length is 1
550
+ // add necessary es5-shim utilities
551
+ var $Array = Array;
552
+ var $Object = Object;
553
+ var ObjectPrototype = $Object.prototype;
554
+ var ArrayPrototype = $Array.prototype;
555
+ var Empty = function Empty() {};
556
+ var to_string = ObjectPrototype.toString;
557
+ var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
558
+ 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; };
559
+ var array_slice = ArrayPrototype.slice;
560
+ var array_concat = ArrayPrototype.concat;
561
+ var array_push = ArrayPrototype.push;
562
+ var max = Math.max;
563
+ // /add necessary es5-shim utilities
564
+
565
+ // 1. Let Target be the this value.
566
+ var target = this;
567
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
568
+ if (!isCallable(target)) {
569
+ throw new TypeError('Function.prototype.bind called on incompatible ' + target);
570
+ }
571
+ // 3. Let A be a new (possibly empty) internal list of all of the
572
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
573
+ // XXX slicedArgs will stand in for "A" if used
574
+ var args = array_slice.call(arguments, 1); // for normal call
575
+ // 4. Let F be a new native ECMAScript object.
576
+ // 11. Set the [[Prototype]] internal property of F to the standard
577
+ // built-in Function prototype object as specified in 15.3.3.1.
578
+ // 12. Set the [[Call]] internal property of F as described in
579
+ // 15.3.4.5.1.
580
+ // 13. Set the [[Construct]] internal property of F as described in
581
+ // 15.3.4.5.2.
582
+ // 14. Set the [[HasInstance]] internal property of F as described in
583
+ // 15.3.4.5.3.
584
+ var bound;
585
+ var binder = function () {
586
+
587
+ if (this instanceof bound) {
588
+ // 15.3.4.5.2 [[Construct]]
589
+ // When the [[Construct]] internal method of a function object,
590
+ // F that was created using the bind function is called with a
591
+ // list of arguments ExtraArgs, the following steps are taken:
592
+ // 1. Let target be the value of F's [[TargetFunction]]
593
+ // internal property.
594
+ // 2. If target has no [[Construct]] internal method, a
595
+ // TypeError exception is thrown.
596
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
597
+ // property.
598
+ // 4. Let args be a new list containing the same values as the
599
+ // list boundArgs in the same order followed by the same
600
+ // values as the list ExtraArgs in the same order.
601
+ // 5. Return the result of calling the [[Construct]] internal
602
+ // method of target providing args as the arguments.
603
+
604
+ var result = target.apply(
605
+ this,
606
+ array_concat.call(args, array_slice.call(arguments))
607
+ );
608
+ if ($Object(result) === result) {
609
+ return result;
610
+ }
611
+ return this;
612
+
613
+ } else {
614
+ // 15.3.4.5.1 [[Call]]
615
+ // When the [[Call]] internal method of a function object, F,
616
+ // which was created using the bind function is called with a
617
+ // this value and a list of arguments ExtraArgs, the following
618
+ // steps are taken:
619
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
620
+ // property.
621
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
622
+ // property.
623
+ // 3. Let target be the value of F's [[TargetFunction]] internal
624
+ // property.
625
+ // 4. Let args be a new list containing the same values as the
626
+ // list boundArgs in the same order followed by the same
627
+ // values as the list ExtraArgs in the same order.
628
+ // 5. Return the result of calling the [[Call]] internal method
629
+ // of target providing boundThis as the this value and
630
+ // providing args as the arguments.
631
+
632
+ // equiv: target.call(this, ...boundArgs, ...args)
633
+ return target.apply(
634
+ that,
635
+ array_concat.call(args, array_slice.call(arguments))
636
+ );
637
+
638
+ }
639
+
640
+ };
641
+
642
+ // 15. If the [[Class]] internal property of Target is "Function", then
643
+ // a. Let L be the length property of Target minus the length of A.
644
+ // b. Set the length own property of F to either 0 or L, whichever is
645
+ // larger.
646
+ // 16. Else set the length own property of F to 0.
647
+
648
+ var boundLength = max(0, target.length - args.length);
649
+
650
+ // 17. Set the attributes of the length own property of F to the values
651
+ // specified in 15.3.5.1.
652
+ var boundArgs = [];
653
+ for (var i = 0; i < boundLength; i++) {
654
+ array_push.call(boundArgs, '$' + i);
655
+ }
656
+
657
+ // XXX Build a dynamic function with desired amount of arguments is the only
658
+ // way to set the length property of a function.
659
+ // In environments where Content Security Policies enabled (Chrome extensions,
660
+ // for ex.) all use of eval or Function costructor throws an exception.
661
+ // However in all of these environments Function.prototype.bind exists
662
+ // and so this code will never be executed.
663
+ bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
664
+
665
+ if (target.prototype) {
666
+ Empty.prototype = target.prototype;
667
+ bound.prototype = new Empty();
668
+ // Clean up dangling references.
669
+ Empty.prototype = null;
670
+ }
671
+
672
+ // TODO
673
+ // 18. Set the [[Extensible]] internal property of F to true.
674
+
675
+ // TODO
676
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
677
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
678
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
679
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
680
+ // false.
681
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
682
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
683
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
684
+ // and false.
685
+
686
+ // TODO
687
+ // NOTE Function objects created using Function.prototype.bind do not
688
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
689
+ // [[Scope]] internal properties.
690
+ // XXX can't delete prototype in pure-js.
691
+
692
+ // 22. Return F.
693
+ return bound;
694
+ }
695
+ });
696
+ })
697
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
698
+
699
+ /* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */
700
+
701
+ var KEY_ENTER = 13;
702
+ var KEY_SPACE = 32;
775
703
 
776
- // Bind an event to handle summary elements
777
- this.polyfillHandleInputs($summary, this.polyfillSetAttributes.bind(this));
778
- };
779
-
780
- /**
781
- * Define a statechange function that updates aria-expanded and style.display
782
- *
783
- * @returns {boolean} Returns true
784
- */
785
- Details.prototype.polyfillSetAttributes = function () {
786
- if (this.$module.hasAttribute('open')) {
787
- this.$module.removeAttribute('open');
788
- this.$summary.setAttribute('aria-expanded', 'false');
789
- this.$content.style.display = 'none';
790
- } else {
791
- this.$module.setAttribute('open', 'open');
792
- this.$summary.setAttribute('aria-expanded', 'true');
793
- this.$content.style.display = '';
704
+ /**
705
+ * Details component
706
+ *
707
+ * @class
708
+ * @param {HTMLElement} $module - HTML element to use for details
709
+ */
710
+ function Details ($module) {
711
+ this.$module = $module;
794
712
  }
795
713
 
796
- return true
797
- };
798
-
799
- /**
800
- * Handle cross-modal click events
801
- *
802
- * @param {object} node - element
803
- * @param {polyfillHandleInputsCallback} callback - function
804
- */
805
- Details.prototype.polyfillHandleInputs = function (node, callback) {
806
- node.addEventListener('keypress', function (event) {
807
- var target = event.target;
808
- // When the key gets pressed - check if it is enter or space
809
- if (event.keyCode === KEY_ENTER || event.keyCode === KEY_SPACE) {
810
- if (target.nodeName.toLowerCase() === 'summary') {
811
- // Prevent space from scrolling the page
812
- // and enter from submitting a form
813
- event.preventDefault();
814
- // Click to let the click event do all the necessary action
815
- if (target.click) {
816
- target.click();
817
- } else {
818
- // except Safari 5.1 and under don't support .click() here
819
- callback(event);
714
+ /**
715
+ * Initialise component
716
+ */
717
+ Details.prototype.init = function () {
718
+ if (!this.$module) {
719
+ return
720
+ }
721
+
722
+ // If there is native details support, we want to avoid running code to polyfill native behaviour.
723
+ var hasNativeDetails = typeof this.$module.open === 'boolean';
724
+
725
+ if (hasNativeDetails) {
726
+ return
727
+ }
728
+
729
+ this.polyfillDetails();
730
+ };
731
+
732
+ /**
733
+ * Polyfill component in older browsers
734
+ */
735
+ Details.prototype.polyfillDetails = function () {
736
+ var $module = this.$module;
737
+
738
+ // Save shortcuts to the inner summary and content elements
739
+ var $summary = this.$summary = $module.getElementsByTagName('summary').item(0);
740
+ var $content = this.$content = $module.getElementsByTagName('div').item(0);
741
+
742
+ // If <details> doesn't have a <summary> and a <div> representing the content
743
+ // it means the required HTML structure is not met so the script will stop
744
+ if (!$summary || !$content) {
745
+ return
746
+ }
747
+
748
+ // If the content doesn't have an ID, assign it one now
749
+ // which we'll need for the summary's aria-controls assignment
750
+ if (!$content.id) {
751
+ $content.id = 'details-content-' + generateUniqueID();
752
+ }
753
+
754
+ // Add ARIA role="group" to details
755
+ $module.setAttribute('role', 'group');
756
+
757
+ // Add role=button to summary
758
+ $summary.setAttribute('role', 'button');
759
+
760
+ // Add aria-controls
761
+ $summary.setAttribute('aria-controls', $content.id);
762
+
763
+ // Set tabIndex so the summary is keyboard accessible for non-native elements
764
+ //
765
+ // We have to use the camelcase `tabIndex` property as there is a bug in IE6/IE7 when we set the correct attribute lowercase:
766
+ // See http://web.archive.org/web/20170120194036/http://www.saliences.com/browserBugs/tabIndex.html for more information.
767
+ $summary.tabIndex = 0;
768
+
769
+ // Detect initial open state
770
+ if (this.$module.hasAttribute('open')) {
771
+ $summary.setAttribute('aria-expanded', 'true');
772
+ } else {
773
+ $summary.setAttribute('aria-expanded', 'false');
774
+ $content.style.display = 'none';
775
+ }
776
+
777
+ // Bind an event to handle summary elements
778
+ this.polyfillHandleInputs(this.polyfillSetAttributes.bind(this));
779
+ };
780
+
781
+ /**
782
+ * Define a statechange function that updates aria-expanded and style.display
783
+ *
784
+ * @returns {boolean} Returns true
785
+ */
786
+ Details.prototype.polyfillSetAttributes = function () {
787
+ if (this.$module.hasAttribute('open')) {
788
+ this.$module.removeAttribute('open');
789
+ this.$summary.setAttribute('aria-expanded', 'false');
790
+ this.$content.style.display = 'none';
791
+ } else {
792
+ this.$module.setAttribute('open', 'open');
793
+ this.$summary.setAttribute('aria-expanded', 'true');
794
+ this.$content.style.display = '';
795
+ }
796
+
797
+ return true
798
+ };
799
+
800
+ /**
801
+ * Handle cross-modal click events
802
+ *
803
+ * @param {polyfillHandleInputsCallback} callback - function
804
+ */
805
+ Details.prototype.polyfillHandleInputs = function (callback) {
806
+ this.$summary.addEventListener('keypress', function (event) {
807
+ var $target = event.target;
808
+ // When the key gets pressed - check if it is enter or space
809
+ if (event.keyCode === KEY_ENTER || event.keyCode === KEY_SPACE) {
810
+ if ($target.nodeName.toLowerCase() === 'summary') {
811
+ // Prevent space from scrolling the page
812
+ // and enter from submitting a form
813
+ event.preventDefault();
814
+ // Click to let the click event do all the necessary action
815
+ if ($target.click) {
816
+ $target.click();
817
+ } else {
818
+ // except Safari 5.1 and under don't support .click() here
819
+ callback(event);
820
+ }
820
821
  }
821
822
  }
822
- }
823
- });
824
-
825
- // Prevent keyup to prevent clicking twice in Firefox when using space key
826
- node.addEventListener('keyup', function (event) {
827
- var target = event.target;
828
- if (event.keyCode === KEY_SPACE) {
829
- if (target.nodeName.toLowerCase() === 'summary') {
830
- event.preventDefault();
823
+ });
824
+
825
+ // Prevent keyup to prevent clicking twice in Firefox when using space key
826
+ this.$summary.addEventListener('keyup', function (event) {
827
+ var $target = event.target;
828
+ if (event.keyCode === KEY_SPACE) {
829
+ if ($target.nodeName.toLowerCase() === 'summary') {
830
+ event.preventDefault();
831
+ }
831
832
  }
832
- }
833
- });
833
+ });
834
834
 
835
- node.addEventListener('click', callback);
836
- };
835
+ this.$summary.addEventListener('click', callback);
836
+ };
837
837
 
838
- /**
839
- * @callback polyfillHandleInputsCallback
840
- * @param {KeyboardEvent} event - Keyboard event
841
- * @returns {undefined}
842
- */
838
+ /**
839
+ * @callback polyfillHandleInputsCallback
840
+ * @param {UIEvent} event - Keyboard or mouse event
841
+ * @returns {void}
842
+ */
843
843
 
844
- return Details;
844
+ return Details;
845
845
 
846
846
  })));
847
+ //# sourceMappingURL=details.js.map