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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/lib/assets/stylesheets/_govuk_tech_docs.scss +13 -0
  4. data/lib/govuk_tech_docs/version.rb +1 -1
  5. data/lib/source/favicon.ico +0 -0
  6. data/lib/source/layouts/_header.erb +13 -15
  7. data/node_modules/govuk-frontend/govuk/all-ie8.scss +8 -0
  8. data/node_modules/govuk-frontend/govuk/all.js +4918 -3796
  9. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +54 -49
  10. data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js +17 -0
  11. data/node_modules/govuk-frontend/govuk/common/index.js +172 -152
  12. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +334 -321
  13. data/node_modules/govuk-frontend/govuk/common.js +171 -151
  14. data/node_modules/govuk-frontend/govuk/components/_all.scss +3 -2
  15. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +26 -7
  16. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +2203 -1650
  17. data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +24 -16
  18. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +34 -11
  19. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +49 -9
  20. data/node_modules/govuk-frontend/govuk/components/button/button.js +961 -916
  21. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +2142 -2038
  22. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +6 -6
  23. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +1204 -1145
  24. data/node_modules/govuk-frontend/govuk/components/details/details.js +826 -799
  25. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +1097 -1044
  26. data/node_modules/govuk-frontend/govuk/components/exit-this-page/_exit-this-page.scss +2 -0
  27. data/node_modules/govuk-frontend/govuk/components/exit-this-page/_index.scss +97 -0
  28. data/node_modules/govuk-frontend/govuk/components/exit-this-page/exit-this-page.js +2120 -0
  29. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +6 -1
  30. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +0 -7
  31. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +6 -0
  32. data/node_modules/govuk-frontend/govuk/components/header/header.js +683 -1003
  33. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +15 -3
  34. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +786 -751
  35. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -5
  36. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +1151 -1105
  37. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +7 -1
  38. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1045 -1014
  39. data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +107 -0
  40. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +1514 -1268
  41. data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +18 -18
  42. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +8 -1
  43. data/node_modules/govuk-frontend/govuk/core/_all.scss +1 -0
  44. data/node_modules/govuk-frontend/govuk/core/_govuk-frontend-version.scss +5 -0
  45. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +5 -2
  46. data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +1 -1
  47. data/node_modules/govuk-frontend/govuk/helpers/_font-faces.scss +1 -1
  48. data/node_modules/govuk-frontend/govuk/helpers/_visually-hidden.scss +12 -0
  49. data/node_modules/govuk-frontend/govuk/i18n.js +371 -364
  50. data/node_modules/govuk-frontend/govuk/objects/_template.scss +20 -0
  51. data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +1 -1
  52. data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +4 -0
  53. data/node_modules/govuk-frontend/govuk/settings/_ie8.scss +16 -0
  54. data/node_modules/govuk-frontend/govuk/settings/_links.scss +5 -1
  55. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +5 -5
  56. data/node_modules/govuk-frontend/govuk/tools/_ie8.scss +38 -2
  57. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +243 -241
  58. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +14 -12
  59. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +18 -16
  60. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +553 -545
  61. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +40 -36
  62. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +257 -250
  63. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +22 -20
  64. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +204 -197
  65. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +204 -197
  66. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +109 -105
  67. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +407 -399
  68. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +242 -238
  69. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +73 -71
  70. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +15 -13
  71. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +18 -16
  72. data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +1 -0
  73. data/package-lock.json +7 -7
  74. data/package.json +1 -1
  75. metadata +8 -3
@@ -4,249 +4,253 @@
4
4
  (factory());
5
5
  }(this, (function () { 'use strict';
6
6
 
7
- (function(undefined) {
8
-
9
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
10
- var detect = (
11
- // In IE8, defineProperty could only act on DOM elements, so full support
12
- // for the feature requires the ability to set a property on an arbitrary object
13
- 'defineProperty' in Object && (function() {
14
- try {
15
- var a = {};
16
- Object.defineProperty(a, 'test', {value:42});
17
- return true;
18
- } catch(e) {
19
- return false
20
- }
21
- }())
22
- );
23
-
24
- if (detect) return
25
-
26
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
27
- (function (nativeDefineProperty) {
28
-
29
- var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
30
- var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
31
- var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
32
-
33
- Object.defineProperty = function defineProperty(object, property, descriptor) {
34
-
35
- // Where native support exists, assume it
36
- if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
37
- return nativeDefineProperty(object, property, descriptor);
38
- }
39
-
40
- if (object === null || !(object instanceof Object || typeof object === 'object')) {
41
- throw new TypeError('Object.defineProperty called on non-object');
42
- }
43
-
44
- if (!(descriptor instanceof Object)) {
45
- throw new TypeError('Property description must be an object');
46
- }
47
-
48
- var propertyString = String(property);
49
- var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
50
- var getterType = 'get' in descriptor && typeof descriptor.get;
51
- var setterType = 'set' in descriptor && typeof descriptor.set;
52
-
53
- // handle descriptor.get
54
- if (getterType) {
55
- if (getterType !== 'function') {
56
- throw new TypeError('Getter must be a function');
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);
57
39
  }
58
- if (!supportsAccessors) {
59
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
40
+
41
+ if (object === null || !(object instanceof Object || typeof object === 'object')) {
42
+ throw new TypeError('Object.defineProperty called on non-object');
60
43
  }
61
- if (hasValueOrWritable) {
62
- throw new TypeError(ERR_VALUE_ACCESSORS);
44
+
45
+ if (!(descriptor instanceof Object)) {
46
+ throw new TypeError('Property description must be an object');
63
47
  }
64
- Object.__defineGetter__.call(object, propertyString, descriptor.get);
65
- } else {
66
- object[propertyString] = descriptor.value;
67
- }
68
-
69
- // handle descriptor.set
70
- if (setterType) {
71
- if (setterType !== 'function') {
72
- throw new TypeError('Setter must be a function');
48
+
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;
53
+
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;
73
68
  }
74
- if (!supportsAccessors) {
75
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
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);
76
82
  }
77
- if (hasValueOrWritable) {
78
- throw new TypeError(ERR_VALUE_ACCESSORS);
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;
79
87
  }
80
- Object.__defineSetter__.call(object, propertyString, descriptor.set);
81
- }
82
-
83
- // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
84
- if ('value' in descriptor) {
85
- object[propertyString] = descriptor.value;
86
- }
87
-
88
- return object;
89
- };
90
- }(Object.defineProperty));
91
- })
92
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
93
-
94
- (function(undefined) {
95
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
96
- var detect = 'bind' in Function.prototype;
97
-
98
- if (detect) return
99
-
100
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
101
- Object.defineProperty(Function.prototype, 'bind', {
102
- value: function bind(that) { // .length is 1
103
- // add necessary es5-shim utilities
104
- var $Array = Array;
105
- var $Object = Object;
106
- var ObjectPrototype = $Object.prototype;
107
- var ArrayPrototype = $Array.prototype;
108
- var Empty = function Empty() {};
109
- var to_string = ObjectPrototype.toString;
110
- var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
111
- var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, tryFunctionObject = function tryFunctionObject(value) { try { fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]'; isCallable = function isCallable(value) { if (typeof value !== 'function') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
112
- var array_slice = ArrayPrototype.slice;
113
- var array_concat = ArrayPrototype.concat;
114
- var array_push = ArrayPrototype.push;
115
- var max = Math.max;
116
- // /add necessary es5-shim utilities
117
-
118
- // 1. Let Target be the this value.
119
- var target = this;
120
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
121
- if (!isCallable(target)) {
122
- throw new TypeError('Function.prototype.bind called on incompatible ' + target);
123
- }
124
- // 3. Let A be a new (possibly empty) internal list of all of the
125
- // argument values provided after thisArg (arg1, arg2 etc), in order.
126
- // XXX slicedArgs will stand in for "A" if used
127
- var args = array_slice.call(arguments, 1); // for normal call
128
- // 4. Let F be a new native ECMAScript object.
129
- // 11. Set the [[Prototype]] internal property of F to the standard
130
- // built-in Function prototype object as specified in 15.3.3.1.
131
- // 12. Set the [[Call]] internal property of F as described in
132
- // 15.3.4.5.1.
133
- // 13. Set the [[Construct]] internal property of F as described in
134
- // 15.3.4.5.2.
135
- // 14. Set the [[HasInstance]] internal property of F as described in
136
- // 15.3.4.5.3.
137
- var bound;
138
- var binder = function () {
139
-
140
- if (this instanceof bound) {
141
- // 15.3.4.5.2 [[Construct]]
142
- // When the [[Construct]] internal method of a function object,
143
- // F that was created using the bind function is called with a
144
- // list of arguments ExtraArgs, the following steps are taken:
145
- // 1. Let target be the value of F's [[TargetFunction]]
146
- // internal property.
147
- // 2. If target has no [[Construct]] internal method, a
148
- // TypeError exception is thrown.
149
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
150
- // property.
151
- // 4. Let args be a new list containing the same values as the
152
- // list boundArgs in the same order followed by the same
153
- // values as the list ExtraArgs in the same order.
154
- // 5. Return the result of calling the [[Construct]] internal
155
- // method of target providing args as the arguments.
156
-
157
- var result = target.apply(
158
- this,
159
- array_concat.call(args, array_slice.call(arguments))
160
- );
161
- if ($Object(result) === result) {
162
- return result;
163
- }
164
- return this;
165
-
166
- } else {
167
- // 15.3.4.5.1 [[Call]]
168
- // When the [[Call]] internal method of a function object, F,
169
- // which was created using the bind function is called with a
170
- // this value and a list of arguments ExtraArgs, the following
171
- // steps are taken:
172
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
173
- // property.
174
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
175
- // property.
176
- // 3. Let target be the value of F's [[TargetFunction]] internal
177
- // property.
178
- // 4. Let args be a new list containing the same values as the
179
- // list boundArgs in the same order followed by the same
180
- // values as the list ExtraArgs in the same order.
181
- // 5. Return the result of calling the [[Call]] internal method
182
- // of target providing boundThis as the this value and
183
- // providing args as the arguments.
184
-
185
- // equiv: target.call(this, ...boundArgs, ...args)
186
- return target.apply(
187
- that,
188
- array_concat.call(args, array_slice.call(arguments))
189
- );
190
-
191
- }
192
-
193
- };
194
-
195
- // 15. If the [[Class]] internal property of Target is "Function", then
196
- // a. Let L be the length property of Target minus the length of A.
197
- // b. Set the length own property of F to either 0 or L, whichever is
198
- // larger.
199
- // 16. Else set the length own property of F to 0.
200
-
201
- var boundLength = max(0, target.length - args.length);
202
-
203
- // 17. Set the attributes of the length own property of F to the values
204
- // specified in 15.3.5.1.
205
- var boundArgs = [];
206
- for (var i = 0; i < boundLength; i++) {
207
- array_push.call(boundArgs, '$' + i);
208
- }
209
-
210
- // XXX Build a dynamic function with desired amount of arguments is the only
211
- // way to set the length property of a function.
212
- // In environments where Content Security Policies enabled (Chrome extensions,
213
- // for ex.) all use of eval or Function costructor throws an exception.
214
- // However in all of these environments Function.prototype.bind exists
215
- // and so this code will never be executed.
216
- bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
217
-
218
- if (target.prototype) {
219
- Empty.prototype = target.prototype;
220
- bound.prototype = new Empty();
221
- // Clean up dangling references.
222
- Empty.prototype = null;
223
- }
224
-
225
- // TODO
226
- // 18. Set the [[Extensible]] internal property of F to true.
227
-
228
- // TODO
229
- // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
230
- // 20. Call the [[DefineOwnProperty]] internal method of F with
231
- // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
232
- // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
233
- // false.
234
- // 21. Call the [[DefineOwnProperty]] internal method of F with
235
- // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
236
- // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
237
- // and false.
238
-
239
- // TODO
240
- // NOTE Function objects created using Function.prototype.bind do not
241
- // have a prototype property or the [[Code]], [[FormalParameters]], and
242
- // [[Scope]] internal properties.
243
- // XXX can't delete prototype in pure-js.
244
-
245
- // 22. Return F.
246
- return bound;
247
- }
248
- });
249
- })
250
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
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
+
97
+ (function(undefined) {
98
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
99
+ var detect = 'bind' in Function.prototype;
100
+
101
+ if (detect) return
102
+
103
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
104
+ Object.defineProperty(Function.prototype, 'bind', {
105
+ value: function bind(that) { // .length is 1
106
+ // add necessary es5-shim utilities
107
+ var $Array = Array;
108
+ var $Object = Object;
109
+ var ObjectPrototype = $Object.prototype;
110
+ var ArrayPrototype = $Array.prototype;
111
+ var Empty = function Empty() {};
112
+ var to_string = ObjectPrototype.toString;
113
+ var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
114
+ 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; };
115
+ var array_slice = ArrayPrototype.slice;
116
+ var array_concat = ArrayPrototype.concat;
117
+ var array_push = ArrayPrototype.push;
118
+ var max = Math.max;
119
+ // /add necessary es5-shim utilities
120
+
121
+ // 1. Let Target be the this value.
122
+ var target = this;
123
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
124
+ if (!isCallable(target)) {
125
+ throw new TypeError('Function.prototype.bind called on incompatible ' + target);
126
+ }
127
+ // 3. Let A be a new (possibly empty) internal list of all of the
128
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
129
+ // XXX slicedArgs will stand in for "A" if used
130
+ var args = array_slice.call(arguments, 1); // for normal call
131
+ // 4. Let F be a new native ECMAScript object.
132
+ // 11. Set the [[Prototype]] internal property of F to the standard
133
+ // built-in Function prototype object as specified in 15.3.3.1.
134
+ // 12. Set the [[Call]] internal property of F as described in
135
+ // 15.3.4.5.1.
136
+ // 13. Set the [[Construct]] internal property of F as described in
137
+ // 15.3.4.5.2.
138
+ // 14. Set the [[HasInstance]] internal property of F as described in
139
+ // 15.3.4.5.3.
140
+ var bound;
141
+ var binder = function () {
142
+
143
+ if (this instanceof bound) {
144
+ // 15.3.4.5.2 [[Construct]]
145
+ // When the [[Construct]] internal method of a function object,
146
+ // F that was created using the bind function is called with a
147
+ // list of arguments ExtraArgs, the following steps are taken:
148
+ // 1. Let target be the value of F's [[TargetFunction]]
149
+ // internal property.
150
+ // 2. If target has no [[Construct]] internal method, a
151
+ // TypeError exception is thrown.
152
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
153
+ // property.
154
+ // 4. Let args be a new list containing the same values as the
155
+ // list boundArgs in the same order followed by the same
156
+ // values as the list ExtraArgs in the same order.
157
+ // 5. Return the result of calling the [[Construct]] internal
158
+ // method of target providing args as the arguments.
159
+
160
+ var result = target.apply(
161
+ this,
162
+ array_concat.call(args, array_slice.call(arguments))
163
+ );
164
+ if ($Object(result) === result) {
165
+ return result;
166
+ }
167
+ return this;
168
+
169
+ } else {
170
+ // 15.3.4.5.1 [[Call]]
171
+ // When the [[Call]] internal method of a function object, F,
172
+ // which was created using the bind function is called with a
173
+ // this value and a list of arguments ExtraArgs, the following
174
+ // steps are taken:
175
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
176
+ // property.
177
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
178
+ // property.
179
+ // 3. Let target be the value of F's [[TargetFunction]] internal
180
+ // property.
181
+ // 4. Let args be a new list containing the same values as the
182
+ // list boundArgs in the same order followed by the same
183
+ // values as the list ExtraArgs in the same order.
184
+ // 5. Return the result of calling the [[Call]] internal method
185
+ // of target providing boundThis as the this value and
186
+ // providing args as the arguments.
187
+
188
+ // equiv: target.call(this, ...boundArgs, ...args)
189
+ return target.apply(
190
+ that,
191
+ array_concat.call(args, array_slice.call(arguments))
192
+ );
193
+
194
+ }
195
+
196
+ };
197
+
198
+ // 15. If the [[Class]] internal property of Target is "Function", then
199
+ // a. Let L be the length property of Target minus the length of A.
200
+ // b. Set the length own property of F to either 0 or L, whichever is
201
+ // larger.
202
+ // 16. Else set the length own property of F to 0.
203
+
204
+ var boundLength = max(0, target.length - args.length);
205
+
206
+ // 17. Set the attributes of the length own property of F to the values
207
+ // specified in 15.3.5.1.
208
+ var boundArgs = [];
209
+ for (var i = 0; i < boundLength; i++) {
210
+ array_push.call(boundArgs, '$' + i);
211
+ }
212
+
213
+ // XXX Build a dynamic function with desired amount of arguments is the only
214
+ // way to set the length property of a function.
215
+ // In environments where Content Security Policies enabled (Chrome extensions,
216
+ // for ex.) all use of eval or Function costructor throws an exception.
217
+ // However in all of these environments Function.prototype.bind exists
218
+ // and so this code will never be executed.
219
+ bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
220
+
221
+ if (target.prototype) {
222
+ Empty.prototype = target.prototype;
223
+ bound.prototype = new Empty();
224
+ // Clean up dangling references.
225
+ Empty.prototype = null;
226
+ }
227
+
228
+ // TODO
229
+ // 18. Set the [[Extensible]] internal property of F to true.
230
+
231
+ // TODO
232
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
233
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
234
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
235
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
236
+ // false.
237
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
238
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
239
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
240
+ // and false.
241
+
242
+ // TODO
243
+ // NOTE Function objects created using Function.prototype.bind do not
244
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
245
+ // [[Scope]] internal properties.
246
+ // XXX can't delete prototype in pure-js.
247
+
248
+ // 22. Return F.
249
+ return bound;
250
+ }
251
+ });
252
+ })
253
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
251
254
 
252
255
  })));
256
+ //# sourceMappingURL=bind.js.map