govuk_tech_docs 3.4.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/assets/stylesheets/_govuk_tech_docs.scss +13 -0
- data/lib/govuk_tech_docs/version.rb +1 -1
- data/lib/source/favicon.ico +0 -0
- data/lib/source/layouts/_header.erb +13 -15
- data/node_modules/govuk-frontend/govuk/all-ie8.scss +8 -0
- data/node_modules/govuk-frontend/govuk/all.js +4918 -3796
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +54 -49
- data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js +17 -0
- data/node_modules/govuk-frontend/govuk/common/index.js +172 -152
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +334 -321
- data/node_modules/govuk-frontend/govuk/common.js +171 -151
- data/node_modules/govuk-frontend/govuk/components/_all.scss +3 -2
- data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +26 -7
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +2203 -1650
- data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +24 -16
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +34 -11
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +49 -9
- data/node_modules/govuk-frontend/govuk/components/button/button.js +961 -916
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +2142 -2038
- data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +6 -6
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +1204 -1145
- data/node_modules/govuk-frontend/govuk/components/details/details.js +826 -799
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +1097 -1044
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/_exit-this-page.scss +2 -0
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/_index.scss +97 -0
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/exit-this-page.js +2120 -0
- data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +6 -1
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +0 -7
- data/node_modules/govuk-frontend/govuk/components/header/_index.scss +6 -0
- data/node_modules/govuk-frontend/govuk/components/header/header.js +683 -1003
- data/node_modules/govuk-frontend/govuk/components/input/_index.scss +15 -3
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +786 -751
- data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -5
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +1151 -1105
- data/node_modules/govuk-frontend/govuk/components/select/_index.scss +7 -1
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1045 -1014
- data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +107 -0
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +1514 -1268
- data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +18 -18
- data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +8 -1
- data/node_modules/govuk-frontend/govuk/core/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/core/_govuk-frontend-version.scss +5 -0
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +5 -2
- data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_font-faces.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_visually-hidden.scss +12 -0
- data/node_modules/govuk-frontend/govuk/i18n.js +371 -364
- data/node_modules/govuk-frontend/govuk/objects/_template.scss +20 -0
- data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +1 -1
- data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +4 -0
- data/node_modules/govuk-frontend/govuk/settings/_ie8.scss +16 -0
- data/node_modules/govuk-frontend/govuk/settings/_links.scss +5 -1
- data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +5 -5
- data/node_modules/govuk-frontend/govuk/tools/_ie8.scss +38 -2
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +243 -241
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +14 -12
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +18 -16
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +553 -545
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +40 -36
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +257 -250
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +22 -20
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +204 -197
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +204 -197
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +109 -105
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +407 -399
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +242 -238
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +73 -71
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +15 -13
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +18 -16
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +1 -0
- data/package-lock.json +7 -7
- data/package.json +1 -1
- metadata +8 -3
@@ -4,370 +4,383 @@
|
|
4
4
|
(factory((global.GOVUKFrontend = {})));
|
5
5
|
}(this, (function (exports) { 'use strict';
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
7
|
+
// @ts-nocheck
|
8
|
+
(function (undefined) {
|
9
|
+
|
10
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
|
11
|
+
var detect = (
|
12
|
+
// In IE8, defineProperty could only act on DOM elements, so full support
|
13
|
+
// for the feature requires the ability to set a property on an arbitrary object
|
14
|
+
'defineProperty' in Object && (function() {
|
15
|
+
try {
|
16
|
+
var a = {};
|
17
|
+
Object.defineProperty(a, 'test', {value:42});
|
18
|
+
return true;
|
19
|
+
} catch(e) {
|
20
|
+
return false
|
21
|
+
}
|
22
|
+
}())
|
23
|
+
);
|
24
|
+
|
25
|
+
if (detect) return
|
26
|
+
|
27
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
|
28
|
+
(function (nativeDefineProperty) {
|
29
|
+
|
30
|
+
var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
|
31
|
+
var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
|
32
|
+
var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
|
33
|
+
|
34
|
+
Object.defineProperty = function defineProperty(object, property, descriptor) {
|
35
|
+
|
36
|
+
// Where native support exists, assume it
|
37
|
+
if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
|
38
|
+
return nativeDefineProperty(object, property, descriptor);
|
39
|
+
}
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
if (object === null || !(object instanceof Object || typeof object === 'object')) {
|
42
|
+
throw new TypeError('Object.defineProperty called on non-object');
|
43
|
+
}
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
if (!(descriptor instanceof Object)) {
|
46
|
+
throw new TypeError('Property description must be an object');
|
47
|
+
}
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
var propertyString = String(property);
|
50
|
+
var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
|
51
|
+
var getterType = 'get' in descriptor && typeof descriptor.get;
|
52
|
+
var setterType = 'set' in descriptor && typeof descriptor.set;
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
// handle descriptor.get
|
55
|
+
if (getterType) {
|
56
|
+
if (getterType !== 'function') {
|
57
|
+
throw new TypeError('Getter must be a function');
|
58
|
+
}
|
59
|
+
if (!supportsAccessors) {
|
60
|
+
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
61
|
+
}
|
62
|
+
if (hasValueOrWritable) {
|
63
|
+
throw new TypeError(ERR_VALUE_ACCESSORS);
|
64
|
+
}
|
65
|
+
Object.__defineGetter__.call(object, propertyString, descriptor.get);
|
66
|
+
} else {
|
67
|
+
object[propertyString] = descriptor.value;
|
63
68
|
}
|
64
|
-
Object.__defineGetter__.call(object, propertyString, descriptor.get);
|
65
|
-
} else {
|
66
|
-
object[propertyString] = descriptor.value;
|
67
|
-
}
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
70
|
+
// handle descriptor.set
|
71
|
+
if (setterType) {
|
72
|
+
if (setterType !== 'function') {
|
73
|
+
throw new TypeError('Setter must be a function');
|
74
|
+
}
|
75
|
+
if (!supportsAccessors) {
|
76
|
+
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
77
|
+
}
|
78
|
+
if (hasValueOrWritable) {
|
79
|
+
throw new TypeError(ERR_VALUE_ACCESSORS);
|
80
|
+
}
|
81
|
+
Object.__defineSetter__.call(object, propertyString, descriptor.set);
|
79
82
|
}
|
80
|
-
Object.__defineSetter__.call(object, propertyString, descriptor.set);
|
81
|
-
}
|
82
83
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
// OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
|
85
|
+
if ('value' in descriptor) {
|
86
|
+
object[propertyString] = descriptor.value;
|
87
|
+
}
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
}(Object.defineProperty));
|
91
|
-
})
|
92
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
89
|
+
return object;
|
90
|
+
};
|
91
|
+
}(Object.defineProperty));
|
92
|
+
})
|
93
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
93
94
|
|
94
|
-
|
95
|
+
// @ts-nocheck
|
96
|
+
(function (undefined) {
|
95
97
|
|
96
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
|
97
|
-
var detect = ("Document" in this);
|
98
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
|
99
|
+
var detect = ("Document" in this);
|
98
100
|
|
99
|
-
if (detect) return
|
101
|
+
if (detect) return
|
100
102
|
|
101
|
-
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
|
102
|
-
if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
|
103
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
|
104
|
+
if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
|
103
105
|
|
104
|
-
|
106
|
+
if (this.HTMLDocument) { // IE8
|
105
107
|
|
106
|
-
|
107
|
-
|
108
|
+
// HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
|
109
|
+
this.Document = this.HTMLDocument;
|
108
110
|
|
109
|
-
|
111
|
+
} else {
|
110
112
|
|
111
|
-
|
112
|
-
|
113
|
-
|
113
|
+
// 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.
|
114
|
+
this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
|
115
|
+
this.Document.prototype = document;
|
116
|
+
}
|
114
117
|
}
|
115
|
-
}
|
116
118
|
|
117
119
|
|
118
|
-
})
|
119
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
120
|
+
})
|
121
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
120
122
|
|
121
|
-
|
123
|
+
// @ts-nocheck
|
122
124
|
|
123
|
-
|
124
|
-
var detect = ('Element' in this && 'HTMLElement' in this);
|
125
|
+
(function(undefined) {
|
125
126
|
|
126
|
-
|
127
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
|
128
|
+
var detect = ('Element' in this && 'HTMLElement' in this);
|
127
129
|
|
128
|
-
|
129
|
-
(function () {
|
130
|
+
if (detect) return
|
130
131
|
|
131
|
-
//
|
132
|
-
|
133
|
-
window.HTMLElement = window.Element;
|
134
|
-
return;
|
135
|
-
}
|
132
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
|
133
|
+
(function () {
|
136
134
|
|
137
|
-
|
138
|
-
|
135
|
+
// IE8
|
136
|
+
if (window.Element && !window.HTMLElement) {
|
137
|
+
window.HTMLElement = window.Element;
|
138
|
+
return;
|
139
|
+
}
|
140
|
+
|
141
|
+
// create Element constructor
|
142
|
+
window.Element = window.HTMLElement = new Function('return function Element() {}')();
|
139
143
|
|
140
|
-
|
141
|
-
|
142
|
-
|
144
|
+
// generate sandboxed iframe
|
145
|
+
var vbody = document.appendChild(document.createElement('body'));
|
146
|
+
var frame = vbody.appendChild(document.createElement('iframe'));
|
143
147
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
+
// use sandboxed iframe to replicate Element functionality
|
149
|
+
var frameDocument = frame.contentWindow.document;
|
150
|
+
var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
|
151
|
+
var cache = {};
|
148
152
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
153
|
+
// polyfill Element.prototype on an element
|
154
|
+
var shiv = function (element, deep) {
|
155
|
+
var
|
156
|
+
childNodes = element.childNodes || [],
|
157
|
+
index = -1,
|
158
|
+
key, value, childNode;
|
155
159
|
|
156
|
-
|
157
|
-
|
160
|
+
if (element.nodeType === 1 && element.constructor !== Element) {
|
161
|
+
element.constructor = Element;
|
158
162
|
|
159
|
-
|
160
|
-
|
161
|
-
|
163
|
+
for (key in cache) {
|
164
|
+
value = cache[key];
|
165
|
+
element[key] = value;
|
166
|
+
}
|
162
167
|
}
|
163
|
-
}
|
164
168
|
|
165
|
-
|
166
|
-
|
167
|
-
|
169
|
+
while (childNode = deep && childNodes[++index]) {
|
170
|
+
shiv(childNode, deep);
|
171
|
+
}
|
172
|
+
|
173
|
+
return element;
|
174
|
+
};
|
168
175
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
if (nonValue || element[propertyName] === oldValue) {
|
189
|
-
element[propertyName] = newValue;
|
176
|
+
var elements = document.getElementsByTagName('*');
|
177
|
+
var nativeCreateElement = document.createElement;
|
178
|
+
var interval;
|
179
|
+
var loopLimit = 100;
|
180
|
+
|
181
|
+
prototype.attachEvent('onpropertychange', function (event) {
|
182
|
+
var
|
183
|
+
propertyName = event.propertyName,
|
184
|
+
nonValue = !cache.hasOwnProperty(propertyName),
|
185
|
+
newValue = prototype[propertyName],
|
186
|
+
oldValue = cache[propertyName],
|
187
|
+
index = -1,
|
188
|
+
element;
|
189
|
+
|
190
|
+
while (element = elements[++index]) {
|
191
|
+
if (element.nodeType === 1) {
|
192
|
+
if (nonValue || element[propertyName] === oldValue) {
|
193
|
+
element[propertyName] = newValue;
|
194
|
+
}
|
190
195
|
}
|
191
196
|
}
|
192
|
-
}
|
193
197
|
|
194
|
-
|
195
|
-
|
198
|
+
cache[propertyName] = newValue;
|
199
|
+
});
|
196
200
|
|
197
|
-
|
201
|
+
prototype.constructor = Element;
|
198
202
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
203
|
+
if (!prototype.hasAttribute) {
|
204
|
+
// <Element>.hasAttribute
|
205
|
+
prototype.hasAttribute = function hasAttribute(name) {
|
206
|
+
return this.getAttribute(name) !== null;
|
207
|
+
};
|
208
|
+
}
|
205
209
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
210
|
+
// Apply Element prototype to the pre-existing DOM as soon as the body element appears.
|
211
|
+
function bodyCheck() {
|
212
|
+
if (!(loopLimit--)) clearTimeout(interval);
|
213
|
+
if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
|
214
|
+
shiv(document, true);
|
215
|
+
if (interval && document.body.prototype) clearTimeout(interval);
|
216
|
+
return (!!document.body.prototype);
|
217
|
+
}
|
218
|
+
return false;
|
213
219
|
}
|
214
|
-
|
220
|
+
if (!bodyCheck()) {
|
221
|
+
document.onreadystatechange = bodyCheck;
|
222
|
+
interval = setInterval(bodyCheck, 25);
|
223
|
+
}
|
224
|
+
|
225
|
+
// Apply to any new elements created after load
|
226
|
+
document.createElement = function createElement(nodeName) {
|
227
|
+
var element = nativeCreateElement(String(nodeName).toLowerCase());
|
228
|
+
return shiv(element);
|
229
|
+
};
|
230
|
+
|
231
|
+
// remove sandboxed iframe
|
232
|
+
document.removeChild(vbody);
|
233
|
+
}());
|
234
|
+
|
235
|
+
})
|
236
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
237
|
+
|
238
|
+
// @ts-nocheck
|
239
|
+
|
240
|
+
(function(undefined) {
|
241
|
+
|
242
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/13cf7c340974d128d557580b5e2dafcd1b1192d1/polyfills/Element/prototype/dataset/detect.js
|
243
|
+
var detect = (function(){
|
244
|
+
if (!document.documentElement.dataset) {
|
245
|
+
return false;
|
246
|
+
}
|
247
|
+
var el = document.createElement('div');
|
248
|
+
el.setAttribute("data-a-b", "c");
|
249
|
+
return el.dataset && el.dataset.aB == "c";
|
250
|
+
}());
|
251
|
+
|
252
|
+
if (detect) return
|
253
|
+
|
254
|
+
// Polyfill derived from https://raw.githubusercontent.com/Financial-Times/polyfill-library/13cf7c340974d128d557580b5e2dafcd1b1192d1/polyfills/Element/prototype/dataset/polyfill.js
|
255
|
+
Object.defineProperty(Element.prototype, 'dataset', {
|
256
|
+
get: function() {
|
257
|
+
var element = this;
|
258
|
+
var attributes = this.attributes;
|
259
|
+
var map = {};
|
260
|
+
|
261
|
+
for (var i = 0; i < attributes.length; i++) {
|
262
|
+
var attribute = attributes[i];
|
263
|
+
|
264
|
+
// This regex has been edited from the original polyfill, to add
|
265
|
+
// support for period (.) separators in data-* attribute names. These
|
266
|
+
// are allowed in the HTML spec, but were not covered by the original
|
267
|
+
// polyfill's regex. We use periods in our i18n implementation.
|
268
|
+
if (attribute && attribute.name && (/^data-\w[.\w-]*$/).test(attribute.name)) {
|
269
|
+
var name = attribute.name;
|
270
|
+
var value = attribute.value;
|
271
|
+
|
272
|
+
var propName = name.substr(5).replace(/-./g, function (prop) {
|
273
|
+
return prop.charAt(1).toUpperCase();
|
274
|
+
});
|
275
|
+
|
276
|
+
// If this browser supports __defineGetter__ and __defineSetter__,
|
277
|
+
// continue using defineProperty. If not (like IE 8 and below), we use
|
278
|
+
// a hacky fallback which at least gives an object in the right format
|
279
|
+
if ('__defineGetter__' in Object.prototype && '__defineSetter__' in Object.prototype) {
|
280
|
+
Object.defineProperty(map, propName, {
|
281
|
+
enumerable: true,
|
282
|
+
get: function() {
|
283
|
+
return this.value;
|
284
|
+
}.bind({value: value || ''}),
|
285
|
+
set: function setter(name, value) {
|
286
|
+
if (typeof value !== 'undefined') {
|
287
|
+
this.setAttribute(name, value);
|
288
|
+
} else {
|
289
|
+
this.removeAttribute(name);
|
290
|
+
}
|
291
|
+
}.bind(element, name)
|
292
|
+
});
|
293
|
+
} else {
|
294
|
+
map[propName] = value;
|
295
|
+
}
|
296
|
+
|
297
|
+
}
|
298
|
+
}
|
299
|
+
|
300
|
+
return map;
|
301
|
+
}
|
302
|
+
});
|
303
|
+
|
304
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
305
|
+
|
306
|
+
// @ts-nocheck
|
307
|
+
(function (undefined) {
|
308
|
+
|
309
|
+
// Detection from https://github.com/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
|
310
|
+
var detect = ('trim' in String.prototype);
|
311
|
+
|
312
|
+
if (detect) return
|
313
|
+
|
314
|
+
// Polyfill from https://github.com/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
|
315
|
+
String.prototype.trim = function () {
|
316
|
+
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
317
|
+
};
|
318
|
+
|
319
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
320
|
+
|
321
|
+
/* eslint-disable es-x/no-string-prototype-trim -- Polyfill imported */
|
322
|
+
|
323
|
+
/**
|
324
|
+
* Normalise string
|
325
|
+
*
|
326
|
+
* 'If it looks like a duck, and it quacks like a duck…' 🦆
|
327
|
+
*
|
328
|
+
* If the passed value looks like a boolean or a number, convert it to a boolean
|
329
|
+
* or number.
|
330
|
+
*
|
331
|
+
* Designed to be used to convert config passed via data attributes (which are
|
332
|
+
* always strings) into something sensible.
|
333
|
+
*
|
334
|
+
* @deprecated Will be made private in v5.0
|
335
|
+
* @param {string} value - The value to normalise
|
336
|
+
* @returns {string | boolean | number | undefined} Normalised data
|
337
|
+
*/
|
338
|
+
function normaliseString (value) {
|
339
|
+
if (typeof value !== 'string') {
|
340
|
+
return value
|
341
|
+
}
|
342
|
+
|
343
|
+
var trimmedValue = value.trim();
|
344
|
+
|
345
|
+
if (trimmedValue === 'true') {
|
346
|
+
return true
|
347
|
+
}
|
348
|
+
|
349
|
+
if (trimmedValue === 'false') {
|
350
|
+
return false
|
351
|
+
}
|
352
|
+
|
353
|
+
// Empty / whitespace-only strings are considered finite so we need to check
|
354
|
+
// the length of the trimmed string as well
|
355
|
+
if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {
|
356
|
+
return Number(trimmedValue)
|
357
|
+
}
|
358
|
+
|
359
|
+
return value
|
215
360
|
}
|
216
|
-
|
217
|
-
|
218
|
-
|
361
|
+
|
362
|
+
/**
|
363
|
+
* Normalise dataset
|
364
|
+
*
|
365
|
+
* Loop over an object and normalise each value using normaliseData function
|
366
|
+
*
|
367
|
+
* @deprecated Will be made private in v5.0
|
368
|
+
* @param {DOMStringMap} dataset - HTML element dataset
|
369
|
+
* @returns {Object<string, unknown>} Normalised dataset
|
370
|
+
*/
|
371
|
+
function normaliseDataset (dataset) {
|
372
|
+
/** @type {Object<string, unknown>} */
|
373
|
+
var out = {};
|
374
|
+
|
375
|
+
for (var key in dataset) {
|
376
|
+
out[key] = normaliseString(dataset[key]);
|
377
|
+
}
|
378
|
+
|
379
|
+
return out
|
219
380
|
}
|
220
381
|
|
221
|
-
|
222
|
-
|
223
|
-
var element = nativeCreateElement(String(nodeName).toLowerCase());
|
224
|
-
return shiv(element);
|
225
|
-
};
|
226
|
-
|
227
|
-
// remove sandboxed iframe
|
228
|
-
document.removeChild(vbody);
|
229
|
-
}());
|
230
|
-
|
231
|
-
})
|
232
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
233
|
-
|
234
|
-
(function(undefined) {
|
235
|
-
|
236
|
-
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/13cf7c340974d128d557580b5e2dafcd1b1192d1/polyfills/Element/prototype/dataset/detect.js
|
237
|
-
var detect = (function(){
|
238
|
-
if (!document.documentElement.dataset) {
|
239
|
-
return false;
|
240
|
-
}
|
241
|
-
var el = document.createElement('div');
|
242
|
-
el.setAttribute("data-a-b", "c");
|
243
|
-
return el.dataset && el.dataset.aB == "c";
|
244
|
-
}());
|
245
|
-
|
246
|
-
if (detect) return
|
247
|
-
|
248
|
-
// Polyfill derived from https://raw.githubusercontent.com/Financial-Times/polyfill-library/13cf7c340974d128d557580b5e2dafcd1b1192d1/polyfills/Element/prototype/dataset/polyfill.js
|
249
|
-
Object.defineProperty(Element.prototype, 'dataset', {
|
250
|
-
get: function() {
|
251
|
-
var element = this;
|
252
|
-
var attributes = this.attributes;
|
253
|
-
var map = {};
|
254
|
-
|
255
|
-
for (var i = 0; i < attributes.length; i++) {
|
256
|
-
var attribute = attributes[i];
|
257
|
-
|
258
|
-
// This regex has been edited from the original polyfill, to add
|
259
|
-
// support for period (.) separators in data-* attribute names. These
|
260
|
-
// are allowed in the HTML spec, but were not covered by the original
|
261
|
-
// polyfill's regex. We use periods in our i18n implementation.
|
262
|
-
if (attribute && attribute.name && (/^data-\w[.\w-]*$/).test(attribute.name)) {
|
263
|
-
var name = attribute.name;
|
264
|
-
var value = attribute.value;
|
265
|
-
|
266
|
-
var propName = name.substr(5).replace(/-./g, function (prop) {
|
267
|
-
return prop.charAt(1).toUpperCase();
|
268
|
-
});
|
269
|
-
|
270
|
-
// If this browser supports __defineGetter__ and __defineSetter__,
|
271
|
-
// continue using defineProperty. If not (like IE 8 and below), we use
|
272
|
-
// a hacky fallback which at least gives an object in the right format
|
273
|
-
if ('__defineGetter__' in Object.prototype && '__defineSetter__' in Object.prototype) {
|
274
|
-
Object.defineProperty(map, propName, {
|
275
|
-
enumerable: true,
|
276
|
-
get: function() {
|
277
|
-
return this.value;
|
278
|
-
}.bind({value: value || ''}),
|
279
|
-
set: function setter(name, value) {
|
280
|
-
if (typeof value !== 'undefined') {
|
281
|
-
this.setAttribute(name, value);
|
282
|
-
} else {
|
283
|
-
this.removeAttribute(name);
|
284
|
-
}
|
285
|
-
}.bind(element, name)
|
286
|
-
});
|
287
|
-
} else {
|
288
|
-
map[propName] = value;
|
289
|
-
}
|
290
|
-
|
291
|
-
}
|
292
|
-
}
|
293
|
-
|
294
|
-
return map;
|
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/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
|
303
|
-
var detect = ('trim' in String.prototype);
|
304
|
-
|
305
|
-
if (detect) return
|
306
|
-
|
307
|
-
// Polyfill from https://github.com/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
|
308
|
-
String.prototype.trim = function () {
|
309
|
-
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
310
|
-
};
|
311
|
-
|
312
|
-
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
313
|
-
|
314
|
-
/**
|
315
|
-
* Normalise string
|
316
|
-
*
|
317
|
-
* 'If it looks like a duck, and it quacks like a duck…' 🦆
|
318
|
-
*
|
319
|
-
* If the passed value looks like a boolean or a number, convert it to a boolean
|
320
|
-
* or number.
|
321
|
-
*
|
322
|
-
* Designed to be used to convert config passed via data attributes (which are
|
323
|
-
* always strings) into something sensible.
|
324
|
-
*
|
325
|
-
* @param {string} value - The value to normalise
|
326
|
-
* @returns {string | boolean | number | undefined} Normalised data
|
327
|
-
*/
|
328
|
-
function normaliseString (value) {
|
329
|
-
if (typeof value !== 'string') {
|
330
|
-
return value
|
331
|
-
}
|
332
|
-
|
333
|
-
var trimmedValue = value.trim();
|
334
|
-
|
335
|
-
if (trimmedValue === 'true') {
|
336
|
-
return true
|
337
|
-
}
|
338
|
-
|
339
|
-
if (trimmedValue === 'false') {
|
340
|
-
return false
|
341
|
-
}
|
342
|
-
|
343
|
-
// Empty / whitespace-only strings are considered finite so we need to check
|
344
|
-
// the length of the trimmed string as well
|
345
|
-
if (trimmedValue.length > 0 && isFinite(trimmedValue)) {
|
346
|
-
return Number(trimmedValue)
|
347
|
-
}
|
348
|
-
|
349
|
-
return value
|
350
|
-
}
|
351
|
-
|
352
|
-
/**
|
353
|
-
* Normalise dataset
|
354
|
-
*
|
355
|
-
* Loop over an object and normalise each value using normaliseData function
|
356
|
-
*
|
357
|
-
* @param {DOMStringMap} dataset - HTML element dataset
|
358
|
-
* @returns {Object<string, string | boolean | number | undefined>} Normalised dataset
|
359
|
-
*/
|
360
|
-
function normaliseDataset (dataset) {
|
361
|
-
var out = {};
|
362
|
-
|
363
|
-
for (var key in dataset) {
|
364
|
-
out[key] = normaliseString(dataset[key]);
|
365
|
-
}
|
366
|
-
|
367
|
-
return out
|
368
|
-
}
|
369
|
-
|
370
|
-
exports.normaliseString = normaliseString;
|
371
|
-
exports.normaliseDataset = normaliseDataset;
|
382
|
+
exports.normaliseString = normaliseString;
|
383
|
+
exports.normaliseDataset = normaliseDataset;
|
372
384
|
|
373
385
|
})));
|
386
|
+
//# sourceMappingURL=normalise-dataset.js.map
|