govuk_tech_docs 3.4.0 → 3.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- 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,586 +4,594 @@
|
|
4
4
|
(factory());
|
5
5
|
}(this, (function () { '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
|
-
|
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;
|
57
68
|
}
|
58
|
-
|
59
|
-
|
69
|
+
|
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);
|
60
82
|
}
|
61
|
-
|
62
|
-
|
83
|
+
|
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;
|
63
87
|
}
|
64
|
-
|
88
|
+
|
89
|
+
return object;
|
90
|
+
};
|
91
|
+
}(Object.defineProperty));
|
92
|
+
})
|
93
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
94
|
+
|
95
|
+
// @ts-nocheck
|
96
|
+
(function (undefined) {
|
97
|
+
|
98
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
|
99
|
+
var detect = (
|
100
|
+
'DOMTokenList' in this && (function (x) {
|
101
|
+
return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
|
102
|
+
})(document.createElement('x'))
|
103
|
+
);
|
104
|
+
|
105
|
+
if (detect) return
|
106
|
+
|
107
|
+
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
|
108
|
+
(function (global) {
|
109
|
+
var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
|
110
|
+
|
111
|
+
if (
|
112
|
+
!nativeImpl ||
|
113
|
+
(
|
114
|
+
!!document.createElementNS &&
|
115
|
+
!!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
|
116
|
+
!(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
|
117
|
+
)
|
118
|
+
) {
|
119
|
+
global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
|
120
|
+
var dpSupport = true;
|
121
|
+
var defineGetter = function (object, name, fn, configurable) {
|
122
|
+
if (Object.defineProperty)
|
123
|
+
Object.defineProperty(object, name, {
|
124
|
+
configurable: false === dpSupport ? true : !!configurable,
|
125
|
+
get: fn
|
126
|
+
});
|
127
|
+
|
128
|
+
else object.__defineGetter__(name, fn);
|
129
|
+
};
|
130
|
+
|
131
|
+
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
|
132
|
+
try {
|
133
|
+
defineGetter({}, "support");
|
134
|
+
}
|
135
|
+
catch (e) {
|
136
|
+
dpSupport = false;
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
var _DOMTokenList = function (el, prop) {
|
141
|
+
var that = this;
|
142
|
+
var tokens = [];
|
143
|
+
var tokenMap = {};
|
144
|
+
var length = 0;
|
145
|
+
var maxLength = 0;
|
146
|
+
var addIndexGetter = function (i) {
|
147
|
+
defineGetter(that, i, function () {
|
148
|
+
preop();
|
149
|
+
return tokens[i];
|
150
|
+
}, false);
|
151
|
+
|
152
|
+
};
|
153
|
+
var reindex = function () {
|
154
|
+
|
155
|
+
/** Define getter functions for array-like access to the tokenList's contents. */
|
156
|
+
if (length >= maxLength)
|
157
|
+
for (; maxLength < length; ++maxLength) {
|
158
|
+
addIndexGetter(maxLength);
|
159
|
+
}
|
160
|
+
};
|
161
|
+
|
162
|
+
/** Helper function called at the start of each class method. Internal use only. */
|
163
|
+
var preop = function () {
|
164
|
+
var error;
|
165
|
+
var i;
|
166
|
+
var args = arguments;
|
167
|
+
var rSpace = /\s+/;
|
168
|
+
|
169
|
+
/** Validate the token/s passed to an instance method, if any. */
|
170
|
+
if (args.length)
|
171
|
+
for (i = 0; i < args.length; ++i)
|
172
|
+
if (rSpace.test(args[i])) {
|
173
|
+
error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
|
174
|
+
error.code = 5;
|
175
|
+
error.name = "InvalidCharacterError";
|
176
|
+
throw error;
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
/** Split the new value apart by whitespace*/
|
181
|
+
if (typeof el[prop] === "object") {
|
182
|
+
tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
|
183
|
+
} else {
|
184
|
+
tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
|
185
|
+
}
|
186
|
+
|
187
|
+
/** Avoid treating blank strings as single-item token lists */
|
188
|
+
if ("" === tokens[0]) tokens = [];
|
189
|
+
|
190
|
+
/** Repopulate the internal token lists */
|
191
|
+
tokenMap = {};
|
192
|
+
for (i = 0; i < tokens.length; ++i)
|
193
|
+
tokenMap[tokens[i]] = true;
|
194
|
+
length = tokens.length;
|
195
|
+
reindex();
|
196
|
+
};
|
197
|
+
|
198
|
+
/** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
|
199
|
+
preop();
|
200
|
+
|
201
|
+
/** Return the number of tokens in the underlying string. Read-only. */
|
202
|
+
defineGetter(that, "length", function () {
|
203
|
+
preop();
|
204
|
+
return length;
|
205
|
+
});
|
206
|
+
|
207
|
+
/** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
|
208
|
+
that.toLocaleString =
|
209
|
+
that.toString = function () {
|
210
|
+
preop();
|
211
|
+
return tokens.join(" ");
|
212
|
+
};
|
213
|
+
|
214
|
+
that.item = function (idx) {
|
215
|
+
preop();
|
216
|
+
return tokens[idx];
|
217
|
+
};
|
218
|
+
|
219
|
+
that.contains = function (token) {
|
220
|
+
preop();
|
221
|
+
return !!tokenMap[token];
|
222
|
+
};
|
223
|
+
|
224
|
+
that.add = function () {
|
225
|
+
preop.apply(that, args = arguments);
|
226
|
+
|
227
|
+
for (var args, token, i = 0, l = args.length; i < l; ++i) {
|
228
|
+
token = args[i];
|
229
|
+
if (!tokenMap[token]) {
|
230
|
+
tokens.push(token);
|
231
|
+
tokenMap[token] = true;
|
232
|
+
}
|
233
|
+
}
|
234
|
+
|
235
|
+
/** Update the targeted attribute of the attached element if the token list's changed. */
|
236
|
+
if (length !== tokens.length) {
|
237
|
+
length = tokens.length >>> 0;
|
238
|
+
if (typeof el[prop] === "object") {
|
239
|
+
el[prop].baseVal = tokens.join(" ");
|
240
|
+
} else {
|
241
|
+
el[prop] = tokens.join(" ");
|
242
|
+
}
|
243
|
+
reindex();
|
244
|
+
}
|
245
|
+
};
|
246
|
+
|
247
|
+
that.remove = function () {
|
248
|
+
preop.apply(that, args = arguments);
|
249
|
+
|
250
|
+
/** Build a hash of token names to compare against when recollecting our token list. */
|
251
|
+
for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
|
252
|
+
ignore[args[i]] = true;
|
253
|
+
delete tokenMap[args[i]];
|
254
|
+
}
|
255
|
+
|
256
|
+
/** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
|
257
|
+
for (i = 0; i < tokens.length; ++i)
|
258
|
+
if (!ignore[tokens[i]]) t.push(tokens[i]);
|
259
|
+
|
260
|
+
tokens = t;
|
261
|
+
length = t.length >>> 0;
|
262
|
+
|
263
|
+
/** Update the targeted attribute of the attached element. */
|
264
|
+
if (typeof el[prop] === "object") {
|
265
|
+
el[prop].baseVal = tokens.join(" ");
|
266
|
+
} else {
|
267
|
+
el[prop] = tokens.join(" ");
|
268
|
+
}
|
269
|
+
reindex();
|
270
|
+
};
|
271
|
+
|
272
|
+
that.toggle = function (token, force) {
|
273
|
+
preop.apply(that, [token]);
|
274
|
+
|
275
|
+
/** Token state's being forced. */
|
276
|
+
if (undefined !== force) {
|
277
|
+
if (force) {
|
278
|
+
that.add(token);
|
279
|
+
return true;
|
280
|
+
} else {
|
281
|
+
that.remove(token);
|
282
|
+
return false;
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
286
|
+
/** Token already exists in tokenList. Remove it, and return FALSE. */
|
287
|
+
if (tokenMap[token]) {
|
288
|
+
that.remove(token);
|
289
|
+
return false;
|
290
|
+
}
|
291
|
+
|
292
|
+
/** Otherwise, add the token and return TRUE. */
|
293
|
+
that.add(token);
|
294
|
+
return true;
|
295
|
+
};
|
296
|
+
|
297
|
+
return that;
|
298
|
+
};
|
299
|
+
|
300
|
+
return _DOMTokenList;
|
301
|
+
}());
|
302
|
+
}
|
303
|
+
|
304
|
+
// Add second argument to native DOMTokenList.toggle() if necessary
|
305
|
+
(function () {
|
306
|
+
var e = document.createElement('span');
|
307
|
+
if (!('classList' in e)) return;
|
308
|
+
e.classList.toggle('x', false);
|
309
|
+
if (!e.classList.contains('x')) return;
|
310
|
+
e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
|
311
|
+
var force = arguments[1];
|
312
|
+
if (force === undefined) {
|
313
|
+
var add = !this.contains(token);
|
314
|
+
this[add ? 'add' : 'remove'](token);
|
315
|
+
return add;
|
316
|
+
}
|
317
|
+
force = !!force;
|
318
|
+
this[force ? 'add' : 'remove'](token);
|
319
|
+
return force;
|
320
|
+
};
|
321
|
+
}());
|
322
|
+
|
323
|
+
// Add multiple arguments to native DOMTokenList.add() if necessary
|
324
|
+
(function () {
|
325
|
+
var e = document.createElement('span');
|
326
|
+
if (!('classList' in e)) return;
|
327
|
+
e.classList.add('a', 'b');
|
328
|
+
if (e.classList.contains('b')) return;
|
329
|
+
var native = e.classList.constructor.prototype.add;
|
330
|
+
e.classList.constructor.prototype.add = function () {
|
331
|
+
var args = arguments;
|
332
|
+
var l = arguments.length;
|
333
|
+
for (var i = 0; i < l; i++) {
|
334
|
+
native.call(this, args[i]);
|
335
|
+
}
|
336
|
+
};
|
337
|
+
}());
|
338
|
+
|
339
|
+
// Add multiple arguments to native DOMTokenList.remove() if necessary
|
340
|
+
(function () {
|
341
|
+
var e = document.createElement('span');
|
342
|
+
if (!('classList' in e)) return;
|
343
|
+
e.classList.add('a');
|
344
|
+
e.classList.add('b');
|
345
|
+
e.classList.remove('a', 'b');
|
346
|
+
if (!e.classList.contains('b')) return;
|
347
|
+
var native = e.classList.constructor.prototype.remove;
|
348
|
+
e.classList.constructor.prototype.remove = function () {
|
349
|
+
var args = arguments;
|
350
|
+
var l = arguments.length;
|
351
|
+
for (var i = 0; i < l; i++) {
|
352
|
+
native.call(this, args[i]);
|
353
|
+
}
|
354
|
+
};
|
355
|
+
}());
|
356
|
+
|
357
|
+
}(this));
|
358
|
+
|
359
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
360
|
+
|
361
|
+
// @ts-nocheck
|
362
|
+
(function (undefined) {
|
363
|
+
|
364
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
|
365
|
+
var detect = ("Document" in this);
|
366
|
+
|
367
|
+
if (detect) return
|
368
|
+
|
369
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
|
370
|
+
if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
|
371
|
+
|
372
|
+
if (this.HTMLDocument) { // IE8
|
373
|
+
|
374
|
+
// HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
|
375
|
+
this.Document = this.HTMLDocument;
|
376
|
+
|
65
377
|
} else {
|
66
|
-
object[propertyString] = descriptor.value;
|
67
|
-
}
|
68
378
|
|
69
|
-
|
70
|
-
|
71
|
-
|
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);
|
379
|
+
// 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.
|
380
|
+
this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
|
381
|
+
this.Document.prototype = document;
|
81
382
|
}
|
383
|
+
}
|
82
384
|
|
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
385
|
|
88
|
-
|
89
|
-
};
|
90
|
-
}(Object.defineProperty));
|
91
|
-
})
|
92
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
93
|
-
|
94
|
-
(function(undefined) {
|
95
|
-
|
96
|
-
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
|
97
|
-
var detect = (
|
98
|
-
'DOMTokenList' in this && (function (x) {
|
99
|
-
return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
|
100
|
-
})(document.createElement('x'))
|
101
|
-
);
|
102
|
-
|
103
|
-
if (detect) return
|
104
|
-
|
105
|
-
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
|
106
|
-
(function (global) {
|
107
|
-
var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
|
108
|
-
|
109
|
-
if (
|
110
|
-
!nativeImpl ||
|
111
|
-
(
|
112
|
-
!!document.createElementNS &&
|
113
|
-
!!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
|
114
|
-
!(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
|
115
|
-
)
|
116
|
-
) {
|
117
|
-
global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
|
118
|
-
var dpSupport = true;
|
119
|
-
var defineGetter = function (object, name, fn, configurable) {
|
120
|
-
if (Object.defineProperty)
|
121
|
-
Object.defineProperty(object, name, {
|
122
|
-
configurable: false === dpSupport ? true : !!configurable,
|
123
|
-
get: fn
|
124
|
-
});
|
125
|
-
|
126
|
-
else object.__defineGetter__(name, fn);
|
127
|
-
};
|
128
|
-
|
129
|
-
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
|
130
|
-
try {
|
131
|
-
defineGetter({}, "support");
|
132
|
-
}
|
133
|
-
catch (e) {
|
134
|
-
dpSupport = false;
|
135
|
-
}
|
136
|
-
|
137
|
-
|
138
|
-
var _DOMTokenList = function (el, prop) {
|
139
|
-
var that = this;
|
140
|
-
var tokens = [];
|
141
|
-
var tokenMap = {};
|
142
|
-
var length = 0;
|
143
|
-
var maxLength = 0;
|
144
|
-
var addIndexGetter = function (i) {
|
145
|
-
defineGetter(that, i, function () {
|
146
|
-
preop();
|
147
|
-
return tokens[i];
|
148
|
-
}, false);
|
149
|
-
|
150
|
-
};
|
151
|
-
var reindex = function () {
|
152
|
-
|
153
|
-
/** Define getter functions for array-like access to the tokenList's contents. */
|
154
|
-
if (length >= maxLength)
|
155
|
-
for (; maxLength < length; ++maxLength) {
|
156
|
-
addIndexGetter(maxLength);
|
157
|
-
}
|
158
|
-
};
|
159
|
-
|
160
|
-
/** Helper function called at the start of each class method. Internal use only. */
|
161
|
-
var preop = function () {
|
162
|
-
var error;
|
163
|
-
var i;
|
164
|
-
var args = arguments;
|
165
|
-
var rSpace = /\s+/;
|
166
|
-
|
167
|
-
/** Validate the token/s passed to an instance method, if any. */
|
168
|
-
if (args.length)
|
169
|
-
for (i = 0; i < args.length; ++i)
|
170
|
-
if (rSpace.test(args[i])) {
|
171
|
-
error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
|
172
|
-
error.code = 5;
|
173
|
-
error.name = "InvalidCharacterError";
|
174
|
-
throw error;
|
175
|
-
}
|
176
|
-
|
177
|
-
|
178
|
-
/** Split the new value apart by whitespace*/
|
179
|
-
if (typeof el[prop] === "object") {
|
180
|
-
tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
|
181
|
-
} else {
|
182
|
-
tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
|
183
|
-
}
|
184
|
-
|
185
|
-
/** Avoid treating blank strings as single-item token lists */
|
186
|
-
if ("" === tokens[0]) tokens = [];
|
187
|
-
|
188
|
-
/** Repopulate the internal token lists */
|
189
|
-
tokenMap = {};
|
190
|
-
for (i = 0; i < tokens.length; ++i)
|
191
|
-
tokenMap[tokens[i]] = true;
|
192
|
-
length = tokens.length;
|
193
|
-
reindex();
|
194
|
-
};
|
195
|
-
|
196
|
-
/** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
|
197
|
-
preop();
|
198
|
-
|
199
|
-
/** Return the number of tokens in the underlying string. Read-only. */
|
200
|
-
defineGetter(that, "length", function () {
|
201
|
-
preop();
|
202
|
-
return length;
|
203
|
-
});
|
204
|
-
|
205
|
-
/** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
|
206
|
-
that.toLocaleString =
|
207
|
-
that.toString = function () {
|
208
|
-
preop();
|
209
|
-
return tokens.join(" ");
|
210
|
-
};
|
211
|
-
|
212
|
-
that.item = function (idx) {
|
213
|
-
preop();
|
214
|
-
return tokens[idx];
|
215
|
-
};
|
216
|
-
|
217
|
-
that.contains = function (token) {
|
218
|
-
preop();
|
219
|
-
return !!tokenMap[token];
|
220
|
-
};
|
221
|
-
|
222
|
-
that.add = function () {
|
223
|
-
preop.apply(that, args = arguments);
|
224
|
-
|
225
|
-
for (var args, token, i = 0, l = args.length; i < l; ++i) {
|
226
|
-
token = args[i];
|
227
|
-
if (!tokenMap[token]) {
|
228
|
-
tokens.push(token);
|
229
|
-
tokenMap[token] = true;
|
230
|
-
}
|
231
|
-
}
|
232
|
-
|
233
|
-
/** Update the targeted attribute of the attached element if the token list's changed. */
|
234
|
-
if (length !== tokens.length) {
|
235
|
-
length = tokens.length >>> 0;
|
236
|
-
if (typeof el[prop] === "object") {
|
237
|
-
el[prop].baseVal = tokens.join(" ");
|
238
|
-
} else {
|
239
|
-
el[prop] = tokens.join(" ");
|
240
|
-
}
|
241
|
-
reindex();
|
242
|
-
}
|
243
|
-
};
|
244
|
-
|
245
|
-
that.remove = function () {
|
246
|
-
preop.apply(that, args = arguments);
|
247
|
-
|
248
|
-
/** Build a hash of token names to compare against when recollecting our token list. */
|
249
|
-
for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
|
250
|
-
ignore[args[i]] = true;
|
251
|
-
delete tokenMap[args[i]];
|
252
|
-
}
|
253
|
-
|
254
|
-
/** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
|
255
|
-
for (i = 0; i < tokens.length; ++i)
|
256
|
-
if (!ignore[tokens[i]]) t.push(tokens[i]);
|
257
|
-
|
258
|
-
tokens = t;
|
259
|
-
length = t.length >>> 0;
|
260
|
-
|
261
|
-
/** Update the targeted attribute of the attached element. */
|
262
|
-
if (typeof el[prop] === "object") {
|
263
|
-
el[prop].baseVal = tokens.join(" ");
|
264
|
-
} else {
|
265
|
-
el[prop] = tokens.join(" ");
|
266
|
-
}
|
267
|
-
reindex();
|
268
|
-
};
|
269
|
-
|
270
|
-
that.toggle = function (token, force) {
|
271
|
-
preop.apply(that, [token]);
|
272
|
-
|
273
|
-
/** Token state's being forced. */
|
274
|
-
if (undefined !== force) {
|
275
|
-
if (force) {
|
276
|
-
that.add(token);
|
277
|
-
return true;
|
278
|
-
} else {
|
279
|
-
that.remove(token);
|
280
|
-
return false;
|
281
|
-
}
|
282
|
-
}
|
283
|
-
|
284
|
-
/** Token already exists in tokenList. Remove it, and return FALSE. */
|
285
|
-
if (tokenMap[token]) {
|
286
|
-
that.remove(token);
|
287
|
-
return false;
|
288
|
-
}
|
289
|
-
|
290
|
-
/** Otherwise, add the token and return TRUE. */
|
291
|
-
that.add(token);
|
292
|
-
return true;
|
293
|
-
};
|
294
|
-
|
295
|
-
return that;
|
296
|
-
};
|
297
|
-
|
298
|
-
return _DOMTokenList;
|
299
|
-
}());
|
300
|
-
}
|
301
|
-
|
302
|
-
// Add second argument to native DOMTokenList.toggle() if necessary
|
303
|
-
(function () {
|
304
|
-
var e = document.createElement('span');
|
305
|
-
if (!('classList' in e)) return;
|
306
|
-
e.classList.toggle('x', false);
|
307
|
-
if (!e.classList.contains('x')) return;
|
308
|
-
e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
|
309
|
-
var force = arguments[1];
|
310
|
-
if (force === undefined) {
|
311
|
-
var add = !this.contains(token);
|
312
|
-
this[add ? 'add' : 'remove'](token);
|
313
|
-
return add;
|
314
|
-
}
|
315
|
-
force = !!force;
|
316
|
-
this[force ? 'add' : 'remove'](token);
|
317
|
-
return force;
|
318
|
-
};
|
319
|
-
}());
|
320
|
-
|
321
|
-
// Add multiple arguments to native DOMTokenList.add() if necessary
|
322
|
-
(function () {
|
323
|
-
var e = document.createElement('span');
|
324
|
-
if (!('classList' in e)) return;
|
325
|
-
e.classList.add('a', 'b');
|
326
|
-
if (e.classList.contains('b')) return;
|
327
|
-
var native = e.classList.constructor.prototype.add;
|
328
|
-
e.classList.constructor.prototype.add = function () {
|
329
|
-
var args = arguments;
|
330
|
-
var l = arguments.length;
|
331
|
-
for (var i = 0; i < l; i++) {
|
332
|
-
native.call(this, args[i]);
|
333
|
-
}
|
334
|
-
};
|
335
|
-
}());
|
336
|
-
|
337
|
-
// Add multiple arguments to native DOMTokenList.remove() if necessary
|
338
|
-
(function () {
|
339
|
-
var e = document.createElement('span');
|
340
|
-
if (!('classList' in e)) return;
|
341
|
-
e.classList.add('a');
|
342
|
-
e.classList.add('b');
|
343
|
-
e.classList.remove('a', 'b');
|
344
|
-
if (!e.classList.contains('b')) return;
|
345
|
-
var native = e.classList.constructor.prototype.remove;
|
346
|
-
e.classList.constructor.prototype.remove = function () {
|
347
|
-
var args = arguments;
|
348
|
-
var l = arguments.length;
|
349
|
-
for (var i = 0; i < l; i++) {
|
350
|
-
native.call(this, args[i]);
|
351
|
-
}
|
352
|
-
};
|
353
|
-
}());
|
354
|
-
|
355
|
-
}(this));
|
356
|
-
|
357
|
-
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
358
|
-
|
359
|
-
(function(undefined) {
|
360
|
-
|
361
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
|
362
|
-
var detect = ("Document" in this);
|
363
|
-
|
364
|
-
if (detect) return
|
365
|
-
|
366
|
-
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
|
367
|
-
if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
|
368
|
-
|
369
|
-
if (this.HTMLDocument) { // IE8
|
370
|
-
|
371
|
-
// HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
|
372
|
-
this.Document = this.HTMLDocument;
|
373
|
-
|
374
|
-
} else {
|
375
|
-
|
376
|
-
// Create an empty function to act as the missing constructor for the document object, attach the document object as its prototype. The function needs to be anonymous else it is hoisted and causes the feature detect to prematurely pass, preventing the assignments below being made.
|
377
|
-
this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
|
378
|
-
this.Document.prototype = document;
|
379
|
-
}
|
380
|
-
}
|
386
|
+
})
|
387
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
381
388
|
|
389
|
+
// @ts-nocheck
|
382
390
|
|
383
|
-
|
384
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
391
|
+
(function(undefined) {
|
385
392
|
|
386
|
-
|
393
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
|
394
|
+
var detect = ('Element' in this && 'HTMLElement' in this);
|
387
395
|
|
388
|
-
|
389
|
-
var detect = ('Element' in this && 'HTMLElement' in this);
|
396
|
+
if (detect) return
|
390
397
|
|
391
|
-
|
398
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
|
399
|
+
(function () {
|
392
400
|
|
393
|
-
//
|
394
|
-
(
|
401
|
+
// IE8
|
402
|
+
if (window.Element && !window.HTMLElement) {
|
403
|
+
window.HTMLElement = window.Element;
|
404
|
+
return;
|
405
|
+
}
|
395
406
|
|
396
|
-
|
397
|
-
|
398
|
-
window.HTMLElement = window.Element;
|
399
|
-
return;
|
400
|
-
}
|
407
|
+
// create Element constructor
|
408
|
+
window.Element = window.HTMLElement = new Function('return function Element() {}')();
|
401
409
|
|
402
|
-
|
403
|
-
|
410
|
+
// generate sandboxed iframe
|
411
|
+
var vbody = document.appendChild(document.createElement('body'));
|
412
|
+
var frame = vbody.appendChild(document.createElement('iframe'));
|
404
413
|
|
405
|
-
|
406
|
-
|
407
|
-
|
414
|
+
// use sandboxed iframe to replicate Element functionality
|
415
|
+
var frameDocument = frame.contentWindow.document;
|
416
|
+
var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
|
417
|
+
var cache = {};
|
408
418
|
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
419
|
+
// polyfill Element.prototype on an element
|
420
|
+
var shiv = function (element, deep) {
|
421
|
+
var
|
422
|
+
childNodes = element.childNodes || [],
|
423
|
+
index = -1,
|
424
|
+
key, value, childNode;
|
413
425
|
|
414
|
-
|
415
|
-
|
416
|
-
var
|
417
|
-
childNodes = element.childNodes || [],
|
418
|
-
index = -1,
|
419
|
-
key, value, childNode;
|
426
|
+
if (element.nodeType === 1 && element.constructor !== Element) {
|
427
|
+
element.constructor = Element;
|
420
428
|
|
421
|
-
|
422
|
-
|
429
|
+
for (key in cache) {
|
430
|
+
value = cache[key];
|
431
|
+
element[key] = value;
|
432
|
+
}
|
433
|
+
}
|
423
434
|
|
424
|
-
|
425
|
-
|
426
|
-
element[key] = value;
|
435
|
+
while (childNode = deep && childNodes[++index]) {
|
436
|
+
shiv(childNode, deep);
|
427
437
|
}
|
428
|
-
}
|
429
438
|
|
430
|
-
|
431
|
-
|
432
|
-
}
|
439
|
+
return element;
|
440
|
+
};
|
433
441
|
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
if (nonValue || element[propertyName] === oldValue) {
|
454
|
-
element[propertyName] = newValue;
|
442
|
+
var elements = document.getElementsByTagName('*');
|
443
|
+
var nativeCreateElement = document.createElement;
|
444
|
+
var interval;
|
445
|
+
var loopLimit = 100;
|
446
|
+
|
447
|
+
prototype.attachEvent('onpropertychange', function (event) {
|
448
|
+
var
|
449
|
+
propertyName = event.propertyName,
|
450
|
+
nonValue = !cache.hasOwnProperty(propertyName),
|
451
|
+
newValue = prototype[propertyName],
|
452
|
+
oldValue = cache[propertyName],
|
453
|
+
index = -1,
|
454
|
+
element;
|
455
|
+
|
456
|
+
while (element = elements[++index]) {
|
457
|
+
if (element.nodeType === 1) {
|
458
|
+
if (nonValue || element[propertyName] === oldValue) {
|
459
|
+
element[propertyName] = newValue;
|
460
|
+
}
|
455
461
|
}
|
456
462
|
}
|
457
|
-
}
|
458
463
|
|
459
|
-
|
460
|
-
|
464
|
+
cache[propertyName] = newValue;
|
465
|
+
});
|
461
466
|
|
462
|
-
|
467
|
+
prototype.constructor = Element;
|
463
468
|
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
469
|
+
if (!prototype.hasAttribute) {
|
470
|
+
// <Element>.hasAttribute
|
471
|
+
prototype.hasAttribute = function hasAttribute(name) {
|
472
|
+
return this.getAttribute(name) !== null;
|
473
|
+
};
|
474
|
+
}
|
470
475
|
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
476
|
+
// Apply Element prototype to the pre-existing DOM as soon as the body element appears.
|
477
|
+
function bodyCheck() {
|
478
|
+
if (!(loopLimit--)) clearTimeout(interval);
|
479
|
+
if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
|
480
|
+
shiv(document, true);
|
481
|
+
if (interval && document.body.prototype) clearTimeout(interval);
|
482
|
+
return (!!document.body.prototype);
|
483
|
+
}
|
484
|
+
return false;
|
478
485
|
}
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
486
|
+
if (!bodyCheck()) {
|
487
|
+
document.onreadystatechange = bodyCheck;
|
488
|
+
interval = setInterval(bodyCheck, 25);
|
489
|
+
}
|
490
|
+
|
491
|
+
// Apply to any new elements created after load
|
492
|
+
document.createElement = function createElement(nodeName) {
|
493
|
+
var element = nativeCreateElement(String(nodeName).toLowerCase());
|
494
|
+
return shiv(element);
|
495
|
+
};
|
485
496
|
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
}
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
(function(
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
addProp(global.HTMLAreaElement, "relList", "rel");
|
585
|
-
}(this));
|
586
|
-
|
587
|
-
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
497
|
+
// remove sandboxed iframe
|
498
|
+
document.removeChild(vbody);
|
499
|
+
}());
|
500
|
+
|
501
|
+
})
|
502
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
503
|
+
|
504
|
+
// @ts-nocheck
|
505
|
+
|
506
|
+
(function(undefined) {
|
507
|
+
|
508
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
|
509
|
+
var detect = (
|
510
|
+
'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
|
511
|
+
var e = document.createElement('span');
|
512
|
+
e.classList.add('a', 'b');
|
513
|
+
return e.classList.contains('b');
|
514
|
+
}())
|
515
|
+
);
|
516
|
+
|
517
|
+
if (detect) return
|
518
|
+
|
519
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.classList&flags=always
|
520
|
+
(function (global) {
|
521
|
+
var dpSupport = true;
|
522
|
+
var defineGetter = function (object, name, fn, configurable) {
|
523
|
+
if (Object.defineProperty)
|
524
|
+
Object.defineProperty(object, name, {
|
525
|
+
configurable: false === dpSupport ? true : !!configurable,
|
526
|
+
get: fn
|
527
|
+
});
|
528
|
+
|
529
|
+
else object.__defineGetter__(name, fn);
|
530
|
+
};
|
531
|
+
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
|
532
|
+
try {
|
533
|
+
defineGetter({}, "support");
|
534
|
+
}
|
535
|
+
catch (e) {
|
536
|
+
dpSupport = false;
|
537
|
+
}
|
538
|
+
/** Polyfills a property with a DOMTokenList */
|
539
|
+
var addProp = function (o, name, attr) {
|
540
|
+
|
541
|
+
defineGetter(o.prototype, name, function () {
|
542
|
+
var tokenList;
|
543
|
+
|
544
|
+
var THIS = this,
|
545
|
+
|
546
|
+
/** Prevent this from firing twice for some reason. What the hell, IE. */
|
547
|
+
gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
|
548
|
+
if(THIS[gibberishProperty]) return tokenList;
|
549
|
+
THIS[gibberishProperty] = true;
|
550
|
+
|
551
|
+
/**
|
552
|
+
* IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
|
553
|
+
*
|
554
|
+
* What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
|
555
|
+
* that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
|
556
|
+
* element instead, this would conflict with element types which use indexed properties (such as forms and
|
557
|
+
* select lists).
|
558
|
+
*/
|
559
|
+
if (false === dpSupport) {
|
560
|
+
|
561
|
+
var visage;
|
562
|
+
var mirror = addProp.mirror || document.createElement("div");
|
563
|
+
var reflections = mirror.childNodes;
|
564
|
+
var l = reflections.length;
|
565
|
+
|
566
|
+
for (var i = 0; i < l; ++i)
|
567
|
+
if (reflections[i]._R === THIS) {
|
568
|
+
visage = reflections[i];
|
569
|
+
break;
|
570
|
+
}
|
571
|
+
|
572
|
+
/** Couldn't find an element's reflection inside the mirror. Materialise one. */
|
573
|
+
visage || (visage = mirror.appendChild(document.createElement("div")));
|
574
|
+
|
575
|
+
tokenList = DOMTokenList.call(visage, THIS, attr);
|
576
|
+
} else tokenList = new DOMTokenList(THIS, attr);
|
577
|
+
|
578
|
+
defineGetter(THIS, name, function () {
|
579
|
+
return tokenList;
|
580
|
+
});
|
581
|
+
delete THIS[gibberishProperty];
|
582
|
+
|
583
|
+
return tokenList;
|
584
|
+
}, true);
|
585
|
+
};
|
586
|
+
|
587
|
+
addProp(global.Element, "classList", "className");
|
588
|
+
addProp(global.HTMLElement, "classList", "className");
|
589
|
+
addProp(global.HTMLLinkElement, "relList", "rel");
|
590
|
+
addProp(global.HTMLAnchorElement, "relList", "rel");
|
591
|
+
addProp(global.HTMLAreaElement, "relList", "rel");
|
592
|
+
}(this));
|
593
|
+
|
594
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
588
595
|
|
589
596
|
})));
|
597
|
+
//# sourceMappingURL=classList.js.map
|