govuk_publishing_components 29.9.0 → 29.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -5
- data/app/assets/javascripts/govuk_publishing_components/analytics/page-content.js +4 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-click-tracking.js +46 -24
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-page-views.js +98 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +3 -0
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +28 -1
- data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-measurer.js +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +20 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +3 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +7 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_organisation-logo.scss +4 -0
- data/app/controllers/govuk_publishing_components/audit_controller.rb +3 -3
- data/app/controllers/govuk_publishing_components/component_guide_controller.rb +0 -9
- data/app/models/govuk_publishing_components/audit_comparer.rb +91 -34
- data/app/views/govuk_publishing_components/audit/_applications.html.erb +20 -9
- data/app/views/govuk_publishing_components/component_guide/index.html.erb +1 -19
- data/app/views/govuk_publishing_components/components/_accordion.html.erb +7 -5
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +1 -3
- data/app/views/govuk_publishing_components/components/_character_count.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_date_input.html.erb +0 -1
- data/app/views/govuk_publishing_components/components/_error_alert.html.erb +6 -3
- data/app/views/govuk_publishing_components/components/_input.html.erb +0 -2
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +23 -5
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +3 -8
- data/app/views/govuk_publishing_components/components/contextual_sidebar/_ukraine_cta.html.erb +18 -19
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +22 -13
- data/app/views/govuk_publishing_components/components/docs/attachment.yml +0 -11
- data/app/views/govuk_publishing_components/components/docs/error_alert.yml +4 -0
- data/config/locales/ar.yml +1 -2
- data/config/locales/az.yml +1 -2
- data/config/locales/be.yml +1 -2
- data/config/locales/bg.yml +1 -2
- data/config/locales/bn.yml +1 -2
- data/config/locales/cs.yml +1 -2
- data/config/locales/cy.yml +1 -2
- data/config/locales/da.yml +1 -2
- data/config/locales/de.yml +1 -2
- data/config/locales/dr.yml +1 -2
- data/config/locales/el.yml +1 -2
- data/config/locales/en.yml +9 -2
- data/config/locales/es-419.yml +1 -2
- data/config/locales/es.yml +1 -2
- data/config/locales/et.yml +1 -2
- data/config/locales/fa.yml +1 -2
- data/config/locales/fi.yml +1 -2
- data/config/locales/fr.yml +1 -2
- data/config/locales/gd.yml +1 -2
- data/config/locales/gu.yml +1 -2
- data/config/locales/he.yml +1 -2
- data/config/locales/hi.yml +1 -2
- data/config/locales/hr.yml +1 -2
- data/config/locales/hu.yml +1 -2
- data/config/locales/hy.yml +1 -2
- data/config/locales/id.yml +1 -2
- data/config/locales/is.yml +1 -2
- data/config/locales/it.yml +1 -2
- data/config/locales/ja.yml +1 -2
- data/config/locales/ka.yml +1 -2
- data/config/locales/kk.yml +1 -2
- data/config/locales/ko.yml +1 -2
- data/config/locales/lt.yml +1 -2
- data/config/locales/lv.yml +1 -2
- data/config/locales/ms.yml +1 -2
- data/config/locales/mt.yml +1 -2
- data/config/locales/nl.yml +1 -2
- data/config/locales/no.yml +1 -2
- data/config/locales/pa-pk.yml +1 -2
- data/config/locales/pa.yml +1 -2
- data/config/locales/pl.yml +1 -2
- data/config/locales/ps.yml +1 -2
- data/config/locales/pt.yml +1 -2
- data/config/locales/ro.yml +1 -2
- data/config/locales/ru.yml +1 -2
- data/config/locales/si.yml +1 -2
- data/config/locales/sk.yml +1 -2
- data/config/locales/sl.yml +1 -2
- data/config/locales/so.yml +1 -2
- data/config/locales/sq.yml +1 -2
- data/config/locales/sr.yml +1 -2
- data/config/locales/sv.yml +1 -2
- data/config/locales/sw.yml +1 -2
- data/config/locales/ta.yml +1 -2
- data/config/locales/th.yml +1 -2
- data/config/locales/tk.yml +1 -2
- data/config/locales/tr.yml +1 -2
- data/config/locales/uk.yml +1 -2
- data/config/locales/ur.yml +1 -2
- data/config/locales/uz.yml +1 -2
- data/config/locales/vi.yml +1 -2
- data/config/locales/zh-hk.yml +1 -2
- data/config/locales/zh-tw.yml +1 -2
- data/config/locales/zh.yml +1 -2
- data/lib/govuk_publishing_components/presenters/attachment_helper.rb +0 -21
- data/lib/govuk_publishing_components/presenters/meta_tags.rb +6 -0
- data/lib/govuk_publishing_components/presenters/public_layout_helper.rb +35 -16
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/govuk/all.js +120 -49
- data/node_modules/govuk-frontend/govuk/components/back-link/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +6 -16
- data/node_modules/govuk-frontend/govuk/components/button/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +120 -49
- data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +33 -17
- data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +1 -4
- data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +3 -2
- data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +22 -10
- data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +23 -23
- data/node_modules/govuk-frontend/govuk/components/date-input/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/details/macro-options.json +4 -4
- data/node_modules/govuk-frontend/govuk/components/error-message/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +3 -3
- data/node_modules/govuk-frontend/govuk/components/fieldset/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +12 -22
- data/node_modules/govuk-frontend/govuk/components/header/_index.scss +13 -3
- data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/hint/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/input/_index.scss +4 -13
- data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +5 -5
- data/node_modules/govuk-frontend/govuk/components/inset-text/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/label/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/panel/macro-options.json +4 -4
- data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -4
- data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +17 -12
- data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +1 -3
- data/node_modules/govuk-frontend/govuk/components/skip-link/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +5 -5
- data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +4 -4
- data/node_modules/govuk-frontend/govuk/components/tabs/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/tag/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/warning-text/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +3 -3
- data/node_modules/govuk-frontend/govuk/helpers/_links.scss +7 -5
- data/node_modules/govuk-frontend/govuk/helpers/_media-queries.scss +2 -2
- data/node_modules/govuk-frontend/govuk/helpers/_shape-arrow.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +3 -3
- data/node_modules/govuk-frontend/govuk/helpers/_typography.scss +2 -2
- data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +10 -26
- data/node_modules/govuk-frontend/govuk/objects/_template.scss +1 -1
- data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +0 -4
- data/node_modules/govuk-frontend/govuk/tools/_exports.scss +1 -1
- data/node_modules/govuk-frontend/govuk/tools/_font-url.scss +1 -1
- data/node_modules/govuk-frontend/govuk/tools/_image-url.scss +1 -1
- data/node_modules/govuk-frontend/govuk/tools/_px-to-em.scss +2 -2
- data/node_modules/govuk-frontend/govuk/tools/_px-to-rem.scss +1 -1
- data/node_modules/govuk-frontend/govuk-esm/all.mjs +88 -0
- data/node_modules/govuk-frontend/govuk-esm/common.mjs +28 -0
- data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +374 -0
- data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +64 -0
- data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +251 -0
- data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +164 -0
- data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +147 -0
- data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +168 -0
- data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +52 -0
- data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +55 -0
- data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +122 -0
- data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +94 -0
- data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +282 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.js +264 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.js +26 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.js +93 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.js +24 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.js +23 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.js +22 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.js +22 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.js +114 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.js +252 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.js +159 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.js +86 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.js +20 -0
- data/node_modules/govuk-frontend/package.json +8 -1
- metadata +29 -3
@@ -0,0 +1,23 @@
|
|
1
|
+
(function(undefined) {
|
2
|
+
|
3
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/matches/detect.js
|
4
|
+
var detect = (
|
5
|
+
'document' in this && "matches" in document.documentElement
|
6
|
+
)
|
7
|
+
|
8
|
+
if (detect) return
|
9
|
+
|
10
|
+
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/matches/polyfill.js
|
11
|
+
Element.prototype.matches = Element.prototype.webkitMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || function matches(selector) {
|
12
|
+
var element = this;
|
13
|
+
var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
|
14
|
+
var index = 0;
|
15
|
+
|
16
|
+
while (elements[index] && elements[index] !== element) {
|
17
|
+
++index;
|
18
|
+
}
|
19
|
+
|
20
|
+
return !!elements[index];
|
21
|
+
};
|
22
|
+
|
23
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.js
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
import '../../Object/defineProperty'
|
2
|
+
import '../../Element'
|
3
|
+
|
4
|
+
(function(undefined) {
|
5
|
+
|
6
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/nextElementSibling/detect.js
|
7
|
+
var detect = (
|
8
|
+
'document' in this && "nextElementSibling" in document.documentElement
|
9
|
+
)
|
10
|
+
|
11
|
+
if (detect) return
|
12
|
+
|
13
|
+
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/nextElementSibling/polyfill.js
|
14
|
+
Object.defineProperty(Element.prototype, "nextElementSibling", {
|
15
|
+
get: function(){
|
16
|
+
var el = this.nextSibling;
|
17
|
+
while (el && el.nodeType !== 1) { el = el.nextSibling; }
|
18
|
+
return el;
|
19
|
+
}
|
20
|
+
});
|
21
|
+
|
22
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import '../../Object/defineProperty'
|
2
|
+
import '../../Element'
|
3
|
+
|
4
|
+
(function(undefined) {
|
5
|
+
|
6
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/previousElementSibling/detect.js
|
7
|
+
var detect = (
|
8
|
+
'document' in this && "previousElementSibling" in document.documentElement
|
9
|
+
)
|
10
|
+
|
11
|
+
if (detect) return
|
12
|
+
|
13
|
+
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/previousElementSibling/polyfill.js
|
14
|
+
Object.defineProperty(Element.prototype, 'previousElementSibling', {
|
15
|
+
get: function(){
|
16
|
+
var el = this.previousSibling;
|
17
|
+
while (el && el.nodeType !== 1) { el = el.previousSibling; }
|
18
|
+
return el;
|
19
|
+
}
|
20
|
+
});
|
21
|
+
|
22
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
@@ -0,0 +1,114 @@
|
|
1
|
+
import './Document'
|
2
|
+
|
3
|
+
(function(undefined) {
|
4
|
+
|
5
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
|
6
|
+
var detect = ('Element' in this && 'HTMLElement' in this)
|
7
|
+
|
8
|
+
if (detect) return
|
9
|
+
|
10
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
|
11
|
+
(function () {
|
12
|
+
|
13
|
+
// IE8
|
14
|
+
if (window.Element && !window.HTMLElement) {
|
15
|
+
window.HTMLElement = window.Element;
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
|
19
|
+
// create Element constructor
|
20
|
+
window.Element = window.HTMLElement = new Function('return function Element() {}')();
|
21
|
+
|
22
|
+
// generate sandboxed iframe
|
23
|
+
var vbody = document.appendChild(document.createElement('body'));
|
24
|
+
var frame = vbody.appendChild(document.createElement('iframe'));
|
25
|
+
|
26
|
+
// use sandboxed iframe to replicate Element functionality
|
27
|
+
var frameDocument = frame.contentWindow.document;
|
28
|
+
var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
|
29
|
+
var cache = {};
|
30
|
+
|
31
|
+
// polyfill Element.prototype on an element
|
32
|
+
var shiv = function (element, deep) {
|
33
|
+
var
|
34
|
+
childNodes = element.childNodes || [],
|
35
|
+
index = -1,
|
36
|
+
key, value, childNode;
|
37
|
+
|
38
|
+
if (element.nodeType === 1 && element.constructor !== Element) {
|
39
|
+
element.constructor = Element;
|
40
|
+
|
41
|
+
for (key in cache) {
|
42
|
+
value = cache[key];
|
43
|
+
element[key] = value;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
while (childNode = deep && childNodes[++index]) {
|
48
|
+
shiv(childNode, deep);
|
49
|
+
}
|
50
|
+
|
51
|
+
return element;
|
52
|
+
};
|
53
|
+
|
54
|
+
var elements = document.getElementsByTagName('*');
|
55
|
+
var nativeCreateElement = document.createElement;
|
56
|
+
var interval;
|
57
|
+
var loopLimit = 100;
|
58
|
+
|
59
|
+
prototype.attachEvent('onpropertychange', function (event) {
|
60
|
+
var
|
61
|
+
propertyName = event.propertyName,
|
62
|
+
nonValue = !cache.hasOwnProperty(propertyName),
|
63
|
+
newValue = prototype[propertyName],
|
64
|
+
oldValue = cache[propertyName],
|
65
|
+
index = -1,
|
66
|
+
element;
|
67
|
+
|
68
|
+
while (element = elements[++index]) {
|
69
|
+
if (element.nodeType === 1) {
|
70
|
+
if (nonValue || element[propertyName] === oldValue) {
|
71
|
+
element[propertyName] = newValue;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
cache[propertyName] = newValue;
|
77
|
+
});
|
78
|
+
|
79
|
+
prototype.constructor = Element;
|
80
|
+
|
81
|
+
if (!prototype.hasAttribute) {
|
82
|
+
// <Element>.hasAttribute
|
83
|
+
prototype.hasAttribute = function hasAttribute(name) {
|
84
|
+
return this.getAttribute(name) !== null;
|
85
|
+
};
|
86
|
+
}
|
87
|
+
|
88
|
+
// Apply Element prototype to the pre-existing DOM as soon as the body element appears.
|
89
|
+
function bodyCheck() {
|
90
|
+
if (!(loopLimit--)) clearTimeout(interval);
|
91
|
+
if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
|
92
|
+
shiv(document, true);
|
93
|
+
if (interval && document.body.prototype) clearTimeout(interval);
|
94
|
+
return (!!document.body.prototype);
|
95
|
+
}
|
96
|
+
return false;
|
97
|
+
}
|
98
|
+
if (!bodyCheck()) {
|
99
|
+
document.onreadystatechange = bodyCheck;
|
100
|
+
interval = setInterval(bodyCheck, 25);
|
101
|
+
}
|
102
|
+
|
103
|
+
// Apply to any new elements created after load
|
104
|
+
document.createElement = function createElement(nodeName) {
|
105
|
+
var element = nativeCreateElement(String(nodeName).toLowerCase());
|
106
|
+
return shiv(element);
|
107
|
+
};
|
108
|
+
|
109
|
+
// remove sandboxed iframe
|
110
|
+
document.removeChild(vbody);
|
111
|
+
}());
|
112
|
+
|
113
|
+
})
|
114
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
@@ -0,0 +1,252 @@
|
|
1
|
+
import './Window'
|
2
|
+
import './Element'
|
3
|
+
import './Object/defineProperty'
|
4
|
+
|
5
|
+
(function(undefined) {
|
6
|
+
|
7
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
|
8
|
+
var detect = (
|
9
|
+
(function(global) {
|
10
|
+
|
11
|
+
if (!('Event' in global)) return false;
|
12
|
+
if (typeof global.Event === 'function') return true;
|
13
|
+
|
14
|
+
try {
|
15
|
+
|
16
|
+
// In IE 9-11, the Event object exists but cannot be instantiated
|
17
|
+
new Event('click');
|
18
|
+
return true;
|
19
|
+
} catch(e) {
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
}(this))
|
23
|
+
)
|
24
|
+
|
25
|
+
if (detect) return
|
26
|
+
|
27
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Event&flags=always
|
28
|
+
(function () {
|
29
|
+
var unlistenableWindowEvents = {
|
30
|
+
click: 1,
|
31
|
+
dblclick: 1,
|
32
|
+
keyup: 1,
|
33
|
+
keypress: 1,
|
34
|
+
keydown: 1,
|
35
|
+
mousedown: 1,
|
36
|
+
mouseup: 1,
|
37
|
+
mousemove: 1,
|
38
|
+
mouseover: 1,
|
39
|
+
mouseenter: 1,
|
40
|
+
mouseleave: 1,
|
41
|
+
mouseout: 1,
|
42
|
+
storage: 1,
|
43
|
+
storagecommit: 1,
|
44
|
+
textinput: 1
|
45
|
+
};
|
46
|
+
|
47
|
+
// This polyfill depends on availability of `document` so will not run in a worker
|
48
|
+
// However, we asssume there are no browsers with worker support that lack proper
|
49
|
+
// support for `Event` within the worker
|
50
|
+
if (typeof document === 'undefined' || typeof window === 'undefined') return;
|
51
|
+
|
52
|
+
function indexOf(array, element) {
|
53
|
+
var
|
54
|
+
index = -1,
|
55
|
+
length = array.length;
|
56
|
+
|
57
|
+
while (++index < length) {
|
58
|
+
if (index in array && array[index] === element) {
|
59
|
+
return index;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
return -1;
|
64
|
+
}
|
65
|
+
|
66
|
+
var existingProto = (window.Event && window.Event.prototype) || null;
|
67
|
+
window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
|
68
|
+
if (!type) {
|
69
|
+
throw new Error('Not enough arguments');
|
70
|
+
}
|
71
|
+
|
72
|
+
var event;
|
73
|
+
// Shortcut if browser supports createEvent
|
74
|
+
if ('createEvent' in document) {
|
75
|
+
event = document.createEvent('Event');
|
76
|
+
var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
|
77
|
+
var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
|
78
|
+
|
79
|
+
event.initEvent(type, bubbles, cancelable);
|
80
|
+
|
81
|
+
return event;
|
82
|
+
}
|
83
|
+
|
84
|
+
event = document.createEventObject();
|
85
|
+
|
86
|
+
event.type = type;
|
87
|
+
event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
|
88
|
+
event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
|
89
|
+
|
90
|
+
return event;
|
91
|
+
};
|
92
|
+
if (existingProto) {
|
93
|
+
Object.defineProperty(window.Event, 'prototype', {
|
94
|
+
configurable: false,
|
95
|
+
enumerable: false,
|
96
|
+
writable: true,
|
97
|
+
value: existingProto
|
98
|
+
});
|
99
|
+
}
|
100
|
+
|
101
|
+
if (!('createEvent' in document)) {
|
102
|
+
window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
|
103
|
+
var
|
104
|
+
element = this,
|
105
|
+
type = arguments[0],
|
106
|
+
listener = arguments[1];
|
107
|
+
|
108
|
+
if (element === window && type in unlistenableWindowEvents) {
|
109
|
+
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.');
|
110
|
+
}
|
111
|
+
|
112
|
+
if (!element._events) {
|
113
|
+
element._events = {};
|
114
|
+
}
|
115
|
+
|
116
|
+
if (!element._events[type]) {
|
117
|
+
element._events[type] = function (event) {
|
118
|
+
var
|
119
|
+
list = element._events[event.type].list,
|
120
|
+
events = list.slice(),
|
121
|
+
index = -1,
|
122
|
+
length = events.length,
|
123
|
+
eventElement;
|
124
|
+
|
125
|
+
event.preventDefault = function preventDefault() {
|
126
|
+
if (event.cancelable !== false) {
|
127
|
+
event.returnValue = false;
|
128
|
+
}
|
129
|
+
};
|
130
|
+
|
131
|
+
event.stopPropagation = function stopPropagation() {
|
132
|
+
event.cancelBubble = true;
|
133
|
+
};
|
134
|
+
|
135
|
+
event.stopImmediatePropagation = function stopImmediatePropagation() {
|
136
|
+
event.cancelBubble = true;
|
137
|
+
event.cancelImmediate = true;
|
138
|
+
};
|
139
|
+
|
140
|
+
event.currentTarget = element;
|
141
|
+
event.relatedTarget = event.fromElement || null;
|
142
|
+
event.target = event.target || event.srcElement || element;
|
143
|
+
event.timeStamp = new Date().getTime();
|
144
|
+
|
145
|
+
if (event.clientX) {
|
146
|
+
event.pageX = event.clientX + document.documentElement.scrollLeft;
|
147
|
+
event.pageY = event.clientY + document.documentElement.scrollTop;
|
148
|
+
}
|
149
|
+
|
150
|
+
while (++index < length && !event.cancelImmediate) {
|
151
|
+
if (index in events) {
|
152
|
+
eventElement = events[index];
|
153
|
+
|
154
|
+
if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
|
155
|
+
eventElement.call(element, event);
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
};
|
160
|
+
|
161
|
+
element._events[type].list = [];
|
162
|
+
|
163
|
+
if (element.attachEvent) {
|
164
|
+
element.attachEvent('on' + type, element._events[type]);
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
element._events[type].list.push(listener);
|
169
|
+
};
|
170
|
+
|
171
|
+
window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
|
172
|
+
var
|
173
|
+
element = this,
|
174
|
+
type = arguments[0],
|
175
|
+
listener = arguments[1],
|
176
|
+
index;
|
177
|
+
|
178
|
+
if (element._events && element._events[type] && element._events[type].list) {
|
179
|
+
index = indexOf(element._events[type].list, listener);
|
180
|
+
|
181
|
+
if (index !== -1) {
|
182
|
+
element._events[type].list.splice(index, 1);
|
183
|
+
|
184
|
+
if (!element._events[type].list.length) {
|
185
|
+
if (element.detachEvent) {
|
186
|
+
element.detachEvent('on' + type, element._events[type]);
|
187
|
+
}
|
188
|
+
delete element._events[type];
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
};
|
193
|
+
|
194
|
+
window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
|
195
|
+
if (!arguments.length) {
|
196
|
+
throw new Error('Not enough arguments');
|
197
|
+
}
|
198
|
+
|
199
|
+
if (!event || typeof event.type !== 'string') {
|
200
|
+
throw new Error('DOM Events Exception 0');
|
201
|
+
}
|
202
|
+
|
203
|
+
var element = this, type = event.type;
|
204
|
+
|
205
|
+
try {
|
206
|
+
if (!event.bubbles) {
|
207
|
+
event.cancelBubble = true;
|
208
|
+
|
209
|
+
var cancelBubbleEvent = function (event) {
|
210
|
+
event.cancelBubble = true;
|
211
|
+
|
212
|
+
(element || window).detachEvent('on' + type, cancelBubbleEvent);
|
213
|
+
};
|
214
|
+
|
215
|
+
this.attachEvent('on' + type, cancelBubbleEvent);
|
216
|
+
}
|
217
|
+
|
218
|
+
this.fireEvent('on' + type, event);
|
219
|
+
} catch (error) {
|
220
|
+
event.target = element;
|
221
|
+
|
222
|
+
do {
|
223
|
+
event.currentTarget = element;
|
224
|
+
|
225
|
+
if ('_events' in element && typeof element._events[type] === 'function') {
|
226
|
+
element._events[type].call(element, event);
|
227
|
+
}
|
228
|
+
|
229
|
+
if (typeof element['on' + type] === 'function') {
|
230
|
+
element['on' + type].call(element, event);
|
231
|
+
}
|
232
|
+
|
233
|
+
element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
|
234
|
+
} while (element && !event.cancelBubble);
|
235
|
+
}
|
236
|
+
|
237
|
+
return true;
|
238
|
+
};
|
239
|
+
|
240
|
+
// Add the DOMContentLoaded Event
|
241
|
+
document.attachEvent('onreadystatechange', function() {
|
242
|
+
if (document.readyState === 'complete') {
|
243
|
+
document.dispatchEvent(new Event('DOMContentLoaded', {
|
244
|
+
bubbles: true
|
245
|
+
}));
|
246
|
+
}
|
247
|
+
});
|
248
|
+
}
|
249
|
+
}());
|
250
|
+
|
251
|
+
})
|
252
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
@@ -0,0 +1,159 @@
|
|
1
|
+
import '../../Object/defineProperty'
|
2
|
+
|
3
|
+
(function(undefined) {
|
4
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
|
5
|
+
var detect = 'bind' in Function.prototype
|
6
|
+
|
7
|
+
if (detect) return
|
8
|
+
|
9
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
|
10
|
+
Object.defineProperty(Function.prototype, 'bind', {
|
11
|
+
value: function bind(that) { // .length is 1
|
12
|
+
// add necessary es5-shim utilities
|
13
|
+
var $Array = Array;
|
14
|
+
var $Object = Object;
|
15
|
+
var ObjectPrototype = $Object.prototype;
|
16
|
+
var ArrayPrototype = $Array.prototype;
|
17
|
+
var Empty = function Empty() {};
|
18
|
+
var to_string = ObjectPrototype.toString;
|
19
|
+
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
20
|
+
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; };
|
21
|
+
var array_slice = ArrayPrototype.slice;
|
22
|
+
var array_concat = ArrayPrototype.concat;
|
23
|
+
var array_push = ArrayPrototype.push;
|
24
|
+
var max = Math.max;
|
25
|
+
// /add necessary es5-shim utilities
|
26
|
+
|
27
|
+
// 1. Let Target be the this value.
|
28
|
+
var target = this;
|
29
|
+
// 2. If IsCallable(Target) is false, throw a TypeError exception.
|
30
|
+
if (!isCallable(target)) {
|
31
|
+
throw new TypeError('Function.prototype.bind called on incompatible ' + target);
|
32
|
+
}
|
33
|
+
// 3. Let A be a new (possibly empty) internal list of all of the
|
34
|
+
// argument values provided after thisArg (arg1, arg2 etc), in order.
|
35
|
+
// XXX slicedArgs will stand in for "A" if used
|
36
|
+
var args = array_slice.call(arguments, 1); // for normal call
|
37
|
+
// 4. Let F be a new native ECMAScript object.
|
38
|
+
// 11. Set the [[Prototype]] internal property of F to the standard
|
39
|
+
// built-in Function prototype object as specified in 15.3.3.1.
|
40
|
+
// 12. Set the [[Call]] internal property of F as described in
|
41
|
+
// 15.3.4.5.1.
|
42
|
+
// 13. Set the [[Construct]] internal property of F as described in
|
43
|
+
// 15.3.4.5.2.
|
44
|
+
// 14. Set the [[HasInstance]] internal property of F as described in
|
45
|
+
// 15.3.4.5.3.
|
46
|
+
var bound;
|
47
|
+
var binder = function () {
|
48
|
+
|
49
|
+
if (this instanceof bound) {
|
50
|
+
// 15.3.4.5.2 [[Construct]]
|
51
|
+
// When the [[Construct]] internal method of a function object,
|
52
|
+
// F that was created using the bind function is called with a
|
53
|
+
// list of arguments ExtraArgs, the following steps are taken:
|
54
|
+
// 1. Let target be the value of F's [[TargetFunction]]
|
55
|
+
// internal property.
|
56
|
+
// 2. If target has no [[Construct]] internal method, a
|
57
|
+
// TypeError exception is thrown.
|
58
|
+
// 3. Let boundArgs be the value of F's [[BoundArgs]] internal
|
59
|
+
// property.
|
60
|
+
// 4. Let args be a new list containing the same values as the
|
61
|
+
// list boundArgs in the same order followed by the same
|
62
|
+
// values as the list ExtraArgs in the same order.
|
63
|
+
// 5. Return the result of calling the [[Construct]] internal
|
64
|
+
// method of target providing args as the arguments.
|
65
|
+
|
66
|
+
var result = target.apply(
|
67
|
+
this,
|
68
|
+
array_concat.call(args, array_slice.call(arguments))
|
69
|
+
);
|
70
|
+
if ($Object(result) === result) {
|
71
|
+
return result;
|
72
|
+
}
|
73
|
+
return this;
|
74
|
+
|
75
|
+
} else {
|
76
|
+
// 15.3.4.5.1 [[Call]]
|
77
|
+
// When the [[Call]] internal method of a function object, F,
|
78
|
+
// which was created using the bind function is called with a
|
79
|
+
// this value and a list of arguments ExtraArgs, the following
|
80
|
+
// steps are taken:
|
81
|
+
// 1. Let boundArgs be the value of F's [[BoundArgs]] internal
|
82
|
+
// property.
|
83
|
+
// 2. Let boundThis be the value of F's [[BoundThis]] internal
|
84
|
+
// property.
|
85
|
+
// 3. Let target be the value of F's [[TargetFunction]] internal
|
86
|
+
// property.
|
87
|
+
// 4. Let args be a new list containing the same values as the
|
88
|
+
// list boundArgs in the same order followed by the same
|
89
|
+
// values as the list ExtraArgs in the same order.
|
90
|
+
// 5. Return the result of calling the [[Call]] internal method
|
91
|
+
// of target providing boundThis as the this value and
|
92
|
+
// providing args as the arguments.
|
93
|
+
|
94
|
+
// equiv: target.call(this, ...boundArgs, ...args)
|
95
|
+
return target.apply(
|
96
|
+
that,
|
97
|
+
array_concat.call(args, array_slice.call(arguments))
|
98
|
+
);
|
99
|
+
|
100
|
+
}
|
101
|
+
|
102
|
+
};
|
103
|
+
|
104
|
+
// 15. If the [[Class]] internal property of Target is "Function", then
|
105
|
+
// a. Let L be the length property of Target minus the length of A.
|
106
|
+
// b. Set the length own property of F to either 0 or L, whichever is
|
107
|
+
// larger.
|
108
|
+
// 16. Else set the length own property of F to 0.
|
109
|
+
|
110
|
+
var boundLength = max(0, target.length - args.length);
|
111
|
+
|
112
|
+
// 17. Set the attributes of the length own property of F to the values
|
113
|
+
// specified in 15.3.5.1.
|
114
|
+
var boundArgs = [];
|
115
|
+
for (var i = 0; i < boundLength; i++) {
|
116
|
+
array_push.call(boundArgs, '$' + i);
|
117
|
+
}
|
118
|
+
|
119
|
+
// XXX Build a dynamic function with desired amount of arguments is the only
|
120
|
+
// way to set the length property of a function.
|
121
|
+
// In environments where Content Security Policies enabled (Chrome extensions,
|
122
|
+
// for ex.) all use of eval or Function costructor throws an exception.
|
123
|
+
// However in all of these environments Function.prototype.bind exists
|
124
|
+
// and so this code will never be executed.
|
125
|
+
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
|
126
|
+
|
127
|
+
if (target.prototype) {
|
128
|
+
Empty.prototype = target.prototype;
|
129
|
+
bound.prototype = new Empty();
|
130
|
+
// Clean up dangling references.
|
131
|
+
Empty.prototype = null;
|
132
|
+
}
|
133
|
+
|
134
|
+
// TODO
|
135
|
+
// 18. Set the [[Extensible]] internal property of F to true.
|
136
|
+
|
137
|
+
// TODO
|
138
|
+
// 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
|
139
|
+
// 20. Call the [[DefineOwnProperty]] internal method of F with
|
140
|
+
// arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
|
141
|
+
// thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
|
142
|
+
// false.
|
143
|
+
// 21. Call the [[DefineOwnProperty]] internal method of F with
|
144
|
+
// arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
|
145
|
+
// [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
|
146
|
+
// and false.
|
147
|
+
|
148
|
+
// TODO
|
149
|
+
// NOTE Function objects created using Function.prototype.bind do not
|
150
|
+
// have a prototype property or the [[Code]], [[FormalParameters]], and
|
151
|
+
// [[Scope]] internal properties.
|
152
|
+
// XXX can't delete prototype in pure-js.
|
153
|
+
|
154
|
+
// 22. Return F.
|
155
|
+
return bound;
|
156
|
+
}
|
157
|
+
});
|
158
|
+
})
|
159
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
@@ -0,0 +1,86 @@
|
|
1
|
+
(function(undefined) {
|
2
|
+
|
3
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
|
4
|
+
var detect = (
|
5
|
+
// In IE8, defineProperty could only act on DOM elements, so full support
|
6
|
+
// for the feature requires the ability to set a property on an arbitrary object
|
7
|
+
'defineProperty' in Object && (function() {
|
8
|
+
try {
|
9
|
+
var a = {};
|
10
|
+
Object.defineProperty(a, 'test', {value:42});
|
11
|
+
return true;
|
12
|
+
} catch(e) {
|
13
|
+
return false
|
14
|
+
}
|
15
|
+
}())
|
16
|
+
)
|
17
|
+
|
18
|
+
if (detect) return
|
19
|
+
|
20
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
|
21
|
+
(function (nativeDefineProperty) {
|
22
|
+
|
23
|
+
var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
|
24
|
+
var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
|
25
|
+
var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
|
26
|
+
|
27
|
+
Object.defineProperty = function defineProperty(object, property, descriptor) {
|
28
|
+
|
29
|
+
// Where native support exists, assume it
|
30
|
+
if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
|
31
|
+
return nativeDefineProperty(object, property, descriptor);
|
32
|
+
}
|
33
|
+
|
34
|
+
if (object === null || !(object instanceof Object || typeof object === 'object')) {
|
35
|
+
throw new TypeError('Object.defineProperty called on non-object');
|
36
|
+
}
|
37
|
+
|
38
|
+
if (!(descriptor instanceof Object)) {
|
39
|
+
throw new TypeError('Property description must be an object');
|
40
|
+
}
|
41
|
+
|
42
|
+
var propertyString = String(property);
|
43
|
+
var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
|
44
|
+
var getterType = 'get' in descriptor && typeof descriptor.get;
|
45
|
+
var setterType = 'set' in descriptor && typeof descriptor.set;
|
46
|
+
|
47
|
+
// handle descriptor.get
|
48
|
+
if (getterType) {
|
49
|
+
if (getterType !== 'function') {
|
50
|
+
throw new TypeError('Getter must be a function');
|
51
|
+
}
|
52
|
+
if (!supportsAccessors) {
|
53
|
+
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
54
|
+
}
|
55
|
+
if (hasValueOrWritable) {
|
56
|
+
throw new TypeError(ERR_VALUE_ACCESSORS);
|
57
|
+
}
|
58
|
+
Object.__defineGetter__.call(object, propertyString, descriptor.get);
|
59
|
+
} else {
|
60
|
+
object[propertyString] = descriptor.value;
|
61
|
+
}
|
62
|
+
|
63
|
+
// handle descriptor.set
|
64
|
+
if (setterType) {
|
65
|
+
if (setterType !== 'function') {
|
66
|
+
throw new TypeError('Setter must be a function');
|
67
|
+
}
|
68
|
+
if (!supportsAccessors) {
|
69
|
+
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
70
|
+
}
|
71
|
+
if (hasValueOrWritable) {
|
72
|
+
throw new TypeError(ERR_VALUE_ACCESSORS);
|
73
|
+
}
|
74
|
+
Object.__defineSetter__.call(object, propertyString, descriptor.set);
|
75
|
+
}
|
76
|
+
|
77
|
+
// OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
|
78
|
+
if ('value' in descriptor) {
|
79
|
+
object[propertyString] = descriptor.value;
|
80
|
+
}
|
81
|
+
|
82
|
+
return object;
|
83
|
+
};
|
84
|
+
}(Object.defineProperty));
|
85
|
+
})
|
86
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|