govuk_publishing_components 17.7.0 → 17.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +3 -24
- data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +6 -18
- data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +35 -45
- data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +0 -4
- data/lib/govuk_publishing_components.rb +0 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/accessible-autocomplete/package.json +1 -1
- data/node_modules/define-properties/package.json +2 -1
- data/node_modules/function-bind/package.json +2 -1
- data/node_modules/has-symbols/package.json +2 -1
- data/node_modules/jsx-ast-utils/CHANGELOG.md +16 -0
- data/node_modules/jsx-ast-utils/__tests__/helper.js +2 -0
- data/node_modules/jsx-ast-utils/__tests__/src/getPropLiteralValue-test.js +39 -3
- data/node_modules/jsx-ast-utils/__tests__/src/getPropValue-test.js +9 -4
- data/node_modules/jsx-ast-utils/lib/values/expressions/ObjectExpression.js +9 -2
- data/node_modules/jsx-ast-utils/lib/values/expressions/index.js +21 -6
- data/node_modules/jsx-ast-utils/lib/values/index.js +5 -1
- data/node_modules/jsx-ast-utils/package.json +35 -31
- data/node_modules/jsx-ast-utils/src/values/expressions/ObjectExpression.js +3 -1
- data/node_modules/jsx-ast-utils/src/values/expressions/index.js +12 -4
- data/node_modules/object-keys/package.json +2 -1
- data/node_modules/object.assign/CHANGELOG.md +179 -0
- data/node_modules/object.assign/LICENSE +21 -0
- data/node_modules/object.assign/README.md +135 -0
- data/node_modules/object.assign/auto.js +3 -0
- data/node_modules/object.assign/dist/browser.js +492 -0
- data/node_modules/object.assign/hasSymbols.js +41 -0
- data/node_modules/object.assign/implementation.js +41 -0
- data/node_modules/object.assign/index.js +17 -0
- data/node_modules/object.assign/package.json +148 -0
- data/node_modules/object.assign/polyfill.js +51 -0
- data/node_modules/object.assign/shim.js +14 -0
- data/node_modules/object.assign/test.sh +53 -0
- data/node_modules/object.assign/test/index.js +17 -0
- data/node_modules/object.assign/test/native.js +47 -0
- data/node_modules/object.assign/test/shimmed.js +50 -0
- data/node_modules/object.assign/test/tests.js +224 -0
- metadata +18 -3
- data/lib/govuk_publishing_components/presenters/cookie_banner_helper.rb +0 -23
@@ -0,0 +1,41 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var keys = require('object-keys');
|
4
|
+
|
5
|
+
module.exports = function hasSymbols() {
|
6
|
+
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
|
7
|
+
if (typeof Symbol.iterator === 'symbol') { return true; }
|
8
|
+
|
9
|
+
var obj = {};
|
10
|
+
var sym = Symbol('test');
|
11
|
+
var symObj = Object(sym);
|
12
|
+
if (typeof sym === 'string') { return false; }
|
13
|
+
|
14
|
+
if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
|
15
|
+
if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
|
16
|
+
|
17
|
+
// temp disabled per https://github.com/ljharb/object.assign/issues/17
|
18
|
+
// if (sym instanceof Symbol) { return false; }
|
19
|
+
// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
|
20
|
+
// if (!(symObj instanceof Symbol)) { return false; }
|
21
|
+
|
22
|
+
var symVal = 42;
|
23
|
+
obj[sym] = symVal;
|
24
|
+
for (sym in obj) { return false; }
|
25
|
+
if (keys(obj).length !== 0) { return false; }
|
26
|
+
if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
|
27
|
+
|
28
|
+
if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
|
29
|
+
|
30
|
+
var syms = Object.getOwnPropertySymbols(obj);
|
31
|
+
if (syms.length !== 1 || syms[0] !== sym) { return false; }
|
32
|
+
|
33
|
+
if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
|
34
|
+
|
35
|
+
if (typeof Object.getOwnPropertyDescriptor === 'function') {
|
36
|
+
var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
|
37
|
+
if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
|
38
|
+
}
|
39
|
+
|
40
|
+
return true;
|
41
|
+
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// modified from https://github.com/es-shims/es6-shim
|
4
|
+
var keys = require('object-keys');
|
5
|
+
var bind = require('function-bind');
|
6
|
+
var canBeObject = function (obj) {
|
7
|
+
return typeof obj !== 'undefined' && obj !== null;
|
8
|
+
};
|
9
|
+
var hasSymbols = require('has-symbols/shams')();
|
10
|
+
var toObject = Object;
|
11
|
+
var push = bind.call(Function.call, Array.prototype.push);
|
12
|
+
var propIsEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
|
13
|
+
var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null;
|
14
|
+
|
15
|
+
module.exports = function assign(target, source1) {
|
16
|
+
if (!canBeObject(target)) { throw new TypeError('target must be an object'); }
|
17
|
+
var objTarget = toObject(target);
|
18
|
+
var s, source, i, props, syms, value, key;
|
19
|
+
for (s = 1; s < arguments.length; ++s) {
|
20
|
+
source = toObject(arguments[s]);
|
21
|
+
props = keys(source);
|
22
|
+
var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols);
|
23
|
+
if (getSymbols) {
|
24
|
+
syms = getSymbols(source);
|
25
|
+
for (i = 0; i < syms.length; ++i) {
|
26
|
+
key = syms[i];
|
27
|
+
if (propIsEnumerable(source, key)) {
|
28
|
+
push(props, key);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
for (i = 0; i < props.length; ++i) {
|
33
|
+
key = props[i];
|
34
|
+
value = source[key];
|
35
|
+
if (propIsEnumerable(source, key)) {
|
36
|
+
objTarget[key] = value;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return objTarget;
|
41
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var defineProperties = require('define-properties');
|
4
|
+
|
5
|
+
var implementation = require('./implementation');
|
6
|
+
var getPolyfill = require('./polyfill');
|
7
|
+
var shim = require('./shim');
|
8
|
+
|
9
|
+
var polyfill = getPolyfill();
|
10
|
+
|
11
|
+
defineProperties(polyfill, {
|
12
|
+
getPolyfill: getPolyfill,
|
13
|
+
implementation: implementation,
|
14
|
+
shim: shim
|
15
|
+
});
|
16
|
+
|
17
|
+
module.exports = polyfill;
|
@@ -0,0 +1,148 @@
|
|
1
|
+
{
|
2
|
+
"_args": [
|
3
|
+
[
|
4
|
+
{
|
5
|
+
"raw": "object.assign@^4.1.0",
|
6
|
+
"scope": null,
|
7
|
+
"escapedName": "object.assign",
|
8
|
+
"name": "object.assign",
|
9
|
+
"rawSpec": "^4.1.0",
|
10
|
+
"spec": ">=4.1.0 <5.0.0",
|
11
|
+
"type": "range"
|
12
|
+
},
|
13
|
+
"/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ/node_modules/jsx-ast-utils"
|
14
|
+
]
|
15
|
+
],
|
16
|
+
"_from": "object.assign@>=4.1.0 <5.0.0",
|
17
|
+
"_id": "object.assign@4.1.0",
|
18
|
+
"_inCache": true,
|
19
|
+
"_location": "/object.assign",
|
20
|
+
"_nodeVersion": "9.3.0",
|
21
|
+
"_npmOperationalInternal": {
|
22
|
+
"host": "s3://npm-registry-packages",
|
23
|
+
"tmp": "tmp/object.assign-4.1.0.tgz_1513887492170_0.7630214935634285"
|
24
|
+
},
|
25
|
+
"_npmUser": {
|
26
|
+
"name": "ljharb",
|
27
|
+
"email": "ljharb@gmail.com"
|
28
|
+
},
|
29
|
+
"_npmVersion": "5.5.1",
|
30
|
+
"_phantomChildren": {},
|
31
|
+
"_requested": {
|
32
|
+
"raw": "object.assign@^4.1.0",
|
33
|
+
"scope": null,
|
34
|
+
"escapedName": "object.assign",
|
35
|
+
"name": "object.assign",
|
36
|
+
"rawSpec": "^4.1.0",
|
37
|
+
"spec": ">=4.1.0 <5.0.0",
|
38
|
+
"type": "range"
|
39
|
+
},
|
40
|
+
"_requiredBy": [
|
41
|
+
"/jsx-ast-utils"
|
42
|
+
],
|
43
|
+
"_resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz",
|
44
|
+
"_shasum": "968bf1100d7956bb3ca086f006f846b3bc4008da",
|
45
|
+
"_shrinkwrap": null,
|
46
|
+
"_spec": "object.assign@^4.1.0",
|
47
|
+
"_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ/node_modules/jsx-ast-utils",
|
48
|
+
"author": {
|
49
|
+
"name": "Jordan Harband"
|
50
|
+
},
|
51
|
+
"bugs": {
|
52
|
+
"url": "https://github.com/ljharb/object.assign/issues"
|
53
|
+
},
|
54
|
+
"dependencies": {
|
55
|
+
"define-properties": "^1.1.2",
|
56
|
+
"function-bind": "^1.1.1",
|
57
|
+
"has-symbols": "^1.0.0",
|
58
|
+
"object-keys": "^1.0.11"
|
59
|
+
},
|
60
|
+
"description": "ES6 spec-compliant Object.assign shim. From https://github.com/es-shims/es6-shim",
|
61
|
+
"devDependencies": {
|
62
|
+
"@es-shims/api": "^2.1.1",
|
63
|
+
"@ljharb/eslint-config": "^12.2.1",
|
64
|
+
"browserify": "^14.5.0",
|
65
|
+
"covert": "^1.1.0",
|
66
|
+
"eslint": "^4.13.1",
|
67
|
+
"for-each": "^0.3.2",
|
68
|
+
"is": "^3.2.1",
|
69
|
+
"jscs": "^3.0.7",
|
70
|
+
"nsp": "^3.1.0",
|
71
|
+
"tape": "^4.8.0"
|
72
|
+
},
|
73
|
+
"directories": {},
|
74
|
+
"dist": {
|
75
|
+
"integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==",
|
76
|
+
"shasum": "968bf1100d7956bb3ca086f006f846b3bc4008da",
|
77
|
+
"tarball": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz"
|
78
|
+
},
|
79
|
+
"engines": {
|
80
|
+
"node": ">= 0.4"
|
81
|
+
},
|
82
|
+
"gitHead": "5fd74aee40aba36e9a8eb0c329abd33a07b93164",
|
83
|
+
"homepage": "https://github.com/ljharb/object.assign#readme",
|
84
|
+
"keywords": [
|
85
|
+
"Object.assign",
|
86
|
+
"assign",
|
87
|
+
"ES6",
|
88
|
+
"extend",
|
89
|
+
"$.extend",
|
90
|
+
"jQuery",
|
91
|
+
"_.extend",
|
92
|
+
"Underscore",
|
93
|
+
"es-shim API",
|
94
|
+
"polyfill",
|
95
|
+
"shim"
|
96
|
+
],
|
97
|
+
"license": "MIT",
|
98
|
+
"main": "index.js",
|
99
|
+
"maintainers": [
|
100
|
+
{
|
101
|
+
"name": "ljharb",
|
102
|
+
"email": "ljharb@gmail.com"
|
103
|
+
}
|
104
|
+
],
|
105
|
+
"name": "object.assign",
|
106
|
+
"optionalDependencies": {},
|
107
|
+
"readme": "ERROR: No README data found!",
|
108
|
+
"repository": {
|
109
|
+
"type": "git",
|
110
|
+
"url": "git://github.com/ljharb/object.assign.git"
|
111
|
+
},
|
112
|
+
"scripts": {
|
113
|
+
"build": "mkdir -p dist && browserify browserShim.js > dist/browser.js",
|
114
|
+
"coverage": "covert test/*.js",
|
115
|
+
"coverage:quiet": "covert test/*.js --quiet",
|
116
|
+
"eslint": "eslint *.js test/*.js",
|
117
|
+
"jscs": "jscs *.js test/*.js",
|
118
|
+
"lint": "npm run --silent jscs && npm run --silent eslint",
|
119
|
+
"posttest": "npm run --silent security",
|
120
|
+
"prepublish": "npm run --silent build",
|
121
|
+
"pretest": "npm run --silent lint && es-shim-api",
|
122
|
+
"security": "nsp check",
|
123
|
+
"test": "npm run --silent tests-only",
|
124
|
+
"test:implementation": "node test/index.js",
|
125
|
+
"test:native": "node test/native.js",
|
126
|
+
"test:shim": "node test/shimmed.js",
|
127
|
+
"tests-only": "npm run --silent test:implementation && npm run --silent test:shim"
|
128
|
+
},
|
129
|
+
"testling": {
|
130
|
+
"files": "test/index.js",
|
131
|
+
"browsers": [
|
132
|
+
"iexplore/6.0..latest",
|
133
|
+
"firefox/3.0..6.0",
|
134
|
+
"firefox/15.0..latest",
|
135
|
+
"firefox/nightly",
|
136
|
+
"chrome/4.0..10.0",
|
137
|
+
"chrome/20.0..latest",
|
138
|
+
"chrome/canary",
|
139
|
+
"opera/10.0..latest",
|
140
|
+
"opera/next",
|
141
|
+
"safari/4.0..latest",
|
142
|
+
"ipad/6.0..latest",
|
143
|
+
"iphone/6.0..latest",
|
144
|
+
"android-browser/4.2"
|
145
|
+
]
|
146
|
+
},
|
147
|
+
"version": "4.1.0"
|
148
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var implementation = require('./implementation');
|
4
|
+
|
5
|
+
var lacksProperEnumerationOrder = function () {
|
6
|
+
if (!Object.assign) {
|
7
|
+
return false;
|
8
|
+
}
|
9
|
+
// v8, specifically in node 4.x, has a bug with incorrect property enumeration order
|
10
|
+
// note: this does not detect the bug unless there's 20 characters
|
11
|
+
var str = 'abcdefghijklmnopqrst';
|
12
|
+
var letters = str.split('');
|
13
|
+
var map = {};
|
14
|
+
for (var i = 0; i < letters.length; ++i) {
|
15
|
+
map[letters[i]] = letters[i];
|
16
|
+
}
|
17
|
+
var obj = Object.assign({}, map);
|
18
|
+
var actual = '';
|
19
|
+
for (var k in obj) {
|
20
|
+
actual += k;
|
21
|
+
}
|
22
|
+
return str !== actual;
|
23
|
+
};
|
24
|
+
|
25
|
+
var assignHasPendingExceptions = function () {
|
26
|
+
if (!Object.assign || !Object.preventExtensions) {
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
// Firefox 37 still has "pending exception" logic in its Object.assign implementation,
|
30
|
+
// which is 72% slower than our shim, and Firefox 40's native implementation.
|
31
|
+
var thrower = Object.preventExtensions({ 1: 2 });
|
32
|
+
try {
|
33
|
+
Object.assign(thrower, 'xy');
|
34
|
+
} catch (e) {
|
35
|
+
return thrower[1] === 'y';
|
36
|
+
}
|
37
|
+
return false;
|
38
|
+
};
|
39
|
+
|
40
|
+
module.exports = function getPolyfill() {
|
41
|
+
if (!Object.assign) {
|
42
|
+
return implementation;
|
43
|
+
}
|
44
|
+
if (lacksProperEnumerationOrder()) {
|
45
|
+
return implementation;
|
46
|
+
}
|
47
|
+
if (assignHasPendingExceptions()) {
|
48
|
+
return implementation;
|
49
|
+
}
|
50
|
+
return Object.assign;
|
51
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var define = require('define-properties');
|
4
|
+
var getPolyfill = require('./polyfill');
|
5
|
+
|
6
|
+
module.exports = function shimAssign() {
|
7
|
+
var polyfill = getPolyfill();
|
8
|
+
define(
|
9
|
+
Object,
|
10
|
+
{ assign: polyfill },
|
11
|
+
{ assign: function () { return Object.assign !== polyfill; } }
|
12
|
+
);
|
13
|
+
return polyfill;
|
14
|
+
};
|
@@ -0,0 +1,53 @@
|
|
1
|
+
###-begin-npm-completion-###
|
2
|
+
#
|
3
|
+
# npm command completion script
|
4
|
+
#
|
5
|
+
# Installation: npm completion >> ~/.bashrc (or ~/.zshrc)
|
6
|
+
# Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm
|
7
|
+
#
|
8
|
+
|
9
|
+
COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
|
10
|
+
COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
|
11
|
+
export COMP_WORDBREAKS
|
12
|
+
|
13
|
+
if type complete &>/dev/null; then
|
14
|
+
_npm_completion () {
|
15
|
+
local si="$IFS"
|
16
|
+
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
|
17
|
+
COMP_LINE="$COMP_LINE" \
|
18
|
+
COMP_POINT="$COMP_POINT" \
|
19
|
+
npm completion -- "${COMP_WORDS[@]}" \
|
20
|
+
2>/dev/null)) || return $?
|
21
|
+
IFS="$si"
|
22
|
+
}
|
23
|
+
complete -F _npm_completion npm
|
24
|
+
elif type compdef &>/dev/null; then
|
25
|
+
_npm_completion() {
|
26
|
+
si=$IFS
|
27
|
+
compadd -- $(COMP_CWORD=$((CURRENT-1)) \
|
28
|
+
COMP_LINE=$BUFFER \
|
29
|
+
COMP_POINT=0 \
|
30
|
+
npm completion -- "${words[@]}" \
|
31
|
+
2>/dev/null)
|
32
|
+
IFS=$si
|
33
|
+
}
|
34
|
+
compdef _npm_completion npm
|
35
|
+
elif type compctl &>/dev/null; then
|
36
|
+
_npm_completion () {
|
37
|
+
local cword line point words si
|
38
|
+
read -Ac words
|
39
|
+
read -cn cword
|
40
|
+
let cword-=1
|
41
|
+
read -l line
|
42
|
+
read -ln point
|
43
|
+
si="$IFS"
|
44
|
+
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
|
45
|
+
COMP_LINE="$line" \
|
46
|
+
COMP_POINT="$point" \
|
47
|
+
npm completion -- "${words[@]}" \
|
48
|
+
2>/dev/null)) || return $?
|
49
|
+
IFS="$si"
|
50
|
+
}
|
51
|
+
compctl -K _npm_completion npm
|
52
|
+
fi
|
53
|
+
###-end-npm-completion-###
|
@@ -0,0 +1,17 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var assign = require('../');
|
4
|
+
var test = require('tape');
|
5
|
+
var runTests = require('./tests');
|
6
|
+
|
7
|
+
test('as a function', function (t) {
|
8
|
+
t.test('bad array/this value', function (st) {
|
9
|
+
st['throws'](function () { assign(undefined); }, TypeError, 'undefined is not an object');
|
10
|
+
st['throws'](function () { assign(null); }, TypeError, 'null is not an object');
|
11
|
+
st.end();
|
12
|
+
});
|
13
|
+
|
14
|
+
runTests(assign, t);
|
15
|
+
|
16
|
+
t.end();
|
17
|
+
});
|
@@ -0,0 +1,47 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var test = require('tape');
|
4
|
+
var defineProperties = require('define-properties');
|
5
|
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
6
|
+
var functionsHaveNames = function f() {}.name === 'f';
|
7
|
+
|
8
|
+
var runTests = require('./tests');
|
9
|
+
|
10
|
+
test('native', function (t) {
|
11
|
+
t.equal(Object.assign.length, 2, 'Object.assign has a length of 2');
|
12
|
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
13
|
+
st.equal(Object.assign.name, 'assign', 'Object.assign has name "assign"');
|
14
|
+
st.end();
|
15
|
+
});
|
16
|
+
|
17
|
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
18
|
+
et.equal(false, isEnumerable.call(Object, 'assign'), 'Object.assign is not enumerable');
|
19
|
+
et.end();
|
20
|
+
});
|
21
|
+
|
22
|
+
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
|
23
|
+
|
24
|
+
t.test('bad object value', { skip: !supportsStrictMode }, function (st) {
|
25
|
+
st['throws'](function () { return Object.assign(undefined); }, TypeError, 'undefined is not an object');
|
26
|
+
st['throws'](function () { return Object.assign(null); }, TypeError, 'null is not an object');
|
27
|
+
st.end();
|
28
|
+
});
|
29
|
+
|
30
|
+
// v8 in node 0.8 and 0.10 have non-enumerable string properties
|
31
|
+
var stringCharsAreEnumerable = isEnumerable.call('xy', 0);
|
32
|
+
t.test('when Object.assign is present and has pending exceptions', { skip: !stringCharsAreEnumerable || !Object.preventExtensions }, function (st) {
|
33
|
+
// Firefox 37 still has "pending exception" logic in its Object.assign implementation,
|
34
|
+
// which is 72% slower than our shim, and Firefox 40's native implementation.
|
35
|
+
var thrower = Object.preventExtensions({ 1: '2' });
|
36
|
+
var error;
|
37
|
+
try { Object.assign(thrower, 'xy'); } catch (e) { error = e; }
|
38
|
+
st.equal(error instanceof TypeError, true, 'error is TypeError');
|
39
|
+
st.equal(thrower[1], '2', 'thrower[1] === "2"');
|
40
|
+
|
41
|
+
st.end();
|
42
|
+
});
|
43
|
+
|
44
|
+
runTests(Object.assign, t);
|
45
|
+
|
46
|
+
t.end();
|
47
|
+
});
|
@@ -0,0 +1,50 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var assign = require('../');
|
4
|
+
assign.shim();
|
5
|
+
|
6
|
+
var test = require('tape');
|
7
|
+
var defineProperties = require('define-properties');
|
8
|
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
9
|
+
var functionsHaveNames = function f() {}.name === 'f';
|
10
|
+
|
11
|
+
var runTests = require('./tests');
|
12
|
+
|
13
|
+
test('shimmed', function (t) {
|
14
|
+
t.equal(Object.assign.length, 2, 'Object.assign has a length of 2');
|
15
|
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
16
|
+
st.equal(Object.assign.name, 'assign', 'Object.assign has name "assign"');
|
17
|
+
st.end();
|
18
|
+
});
|
19
|
+
|
20
|
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
21
|
+
et.equal(false, isEnumerable.call(Object, 'assign'), 'Object.assign is not enumerable');
|
22
|
+
et.end();
|
23
|
+
});
|
24
|
+
|
25
|
+
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
|
26
|
+
|
27
|
+
t.test('bad object value', { skip: !supportsStrictMode }, function (st) {
|
28
|
+
st['throws'](function () { return Object.assign(undefined); }, TypeError, 'undefined is not an object');
|
29
|
+
st['throws'](function () { return Object.assign(null); }, TypeError, 'null is not an object');
|
30
|
+
st.end();
|
31
|
+
});
|
32
|
+
|
33
|
+
// v8 in node 0.8 and 0.10 have non-enumerable string properties
|
34
|
+
var stringCharsAreEnumerable = isEnumerable.call('xy', 0);
|
35
|
+
t.test('when Object.assign is present and has pending exceptions', { skip: !stringCharsAreEnumerable || !Object.preventExtensions }, function (st) {
|
36
|
+
// Firefox 37 still has "pending exception" logic in its Object.assign implementation,
|
37
|
+
// which is 72% slower than our shim, and Firefox 40's native implementation.
|
38
|
+
var thrower = Object.preventExtensions({ 1: '2' });
|
39
|
+
var error;
|
40
|
+
try { Object.assign(thrower, 'xy'); } catch (e) { error = e; }
|
41
|
+
st.equal(error instanceof TypeError, true, 'error is TypeError');
|
42
|
+
st.equal(thrower[1], '2', 'thrower[1] === "2"');
|
43
|
+
|
44
|
+
st.end();
|
45
|
+
});
|
46
|
+
|
47
|
+
runTests(Object.assign, t);
|
48
|
+
|
49
|
+
t.end();
|
50
|
+
});
|