govuk_publishing_components 17.7.0 → 17.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +3 -24
  3. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +6 -18
  4. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +35 -45
  5. data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +0 -4
  6. data/lib/govuk_publishing_components.rb +0 -1
  7. data/lib/govuk_publishing_components/version.rb +1 -1
  8. data/node_modules/accessible-autocomplete/package.json +1 -1
  9. data/node_modules/define-properties/package.json +2 -1
  10. data/node_modules/function-bind/package.json +2 -1
  11. data/node_modules/has-symbols/package.json +2 -1
  12. data/node_modules/jsx-ast-utils/CHANGELOG.md +16 -0
  13. data/node_modules/jsx-ast-utils/__tests__/helper.js +2 -0
  14. data/node_modules/jsx-ast-utils/__tests__/src/getPropLiteralValue-test.js +39 -3
  15. data/node_modules/jsx-ast-utils/__tests__/src/getPropValue-test.js +9 -4
  16. data/node_modules/jsx-ast-utils/lib/values/expressions/ObjectExpression.js +9 -2
  17. data/node_modules/jsx-ast-utils/lib/values/expressions/index.js +21 -6
  18. data/node_modules/jsx-ast-utils/lib/values/index.js +5 -1
  19. data/node_modules/jsx-ast-utils/package.json +35 -31
  20. data/node_modules/jsx-ast-utils/src/values/expressions/ObjectExpression.js +3 -1
  21. data/node_modules/jsx-ast-utils/src/values/expressions/index.js +12 -4
  22. data/node_modules/object-keys/package.json +2 -1
  23. data/node_modules/object.assign/CHANGELOG.md +179 -0
  24. data/node_modules/object.assign/LICENSE +21 -0
  25. data/node_modules/object.assign/README.md +135 -0
  26. data/node_modules/object.assign/auto.js +3 -0
  27. data/node_modules/object.assign/dist/browser.js +492 -0
  28. data/node_modules/object.assign/hasSymbols.js +41 -0
  29. data/node_modules/object.assign/implementation.js +41 -0
  30. data/node_modules/object.assign/index.js +17 -0
  31. data/node_modules/object.assign/package.json +148 -0
  32. data/node_modules/object.assign/polyfill.js +51 -0
  33. data/node_modules/object.assign/shim.js +14 -0
  34. data/node_modules/object.assign/test.sh +53 -0
  35. data/node_modules/object.assign/test/index.js +17 -0
  36. data/node_modules/object.assign/test/native.js +47 -0
  37. data/node_modules/object.assign/test/shimmed.js +50 -0
  38. data/node_modules/object.assign/test/tests.js +224 -0
  39. metadata +18 -3
  40. data/lib/govuk_publishing_components/presenters/cookie_banner_helper.rb +0 -23
@@ -0,0 +1,224 @@
1
+ 'use strict';
2
+
3
+ var hasSymbols = require('has-symbols/shams')();
4
+ var forEach = require('for-each');
5
+
6
+ module.exports = function (assign, t) {
7
+ t.test('error cases', function (st) {
8
+ st['throws'](function () { assign(null); }, TypeError, 'target must be an object');
9
+ st['throws'](function () { assign(undefined); }, TypeError, 'target must be an object');
10
+ st['throws'](function () { assign(null, {}); }, TypeError, 'target must be an object');
11
+ st['throws'](function () { assign(undefined, {}); }, TypeError, 'target must be an object');
12
+ st.end();
13
+ });
14
+
15
+ t.test('non-object target, no sources', function (st) {
16
+ var bool = assign(true);
17
+ st.equal(typeof bool, 'object', 'bool is object');
18
+ st.equal(Boolean.prototype.valueOf.call(bool), true, 'bool coerces to `true`');
19
+
20
+ var number = assign(1);
21
+ st.equal(typeof number, 'object', 'number is object');
22
+ st.equal(Number.prototype.valueOf.call(number), 1, 'number coerces to `1`');
23
+
24
+ var string = assign('1');
25
+ st.equal(typeof string, 'object', 'number is object');
26
+ st.equal(String.prototype.valueOf.call(string), '1', 'number coerces to `"1"`');
27
+
28
+ st.end();
29
+ });
30
+
31
+ t.test('non-object target, with sources', function (st) {
32
+ var signal = {};
33
+
34
+ st.test('boolean', function (st2) {
35
+ var bool = assign(true, { a: signal });
36
+ st2.equal(typeof bool, 'object', 'bool is object');
37
+ st.equal(Boolean.prototype.valueOf.call(bool), true, 'bool coerces to `true`');
38
+ st2.equal(bool.a, signal, 'source properties copied');
39
+ st2.end();
40
+ });
41
+
42
+ st.test('number', function (st2) {
43
+ var number = assign(1, { a: signal });
44
+ st2.equal(typeof number, 'object', 'number is object');
45
+ st2.equal(Number.prototype.valueOf.call(number), 1, 'number coerces to `1`');
46
+ st2.equal(number.a, signal, 'source properties copied');
47
+ st2.end();
48
+ });
49
+
50
+ st.test('string', function (st2) {
51
+ var string = assign('1', { a: signal });
52
+ st2.equal(typeof string, 'object', 'number is object');
53
+ st2.equal(String.prototype.valueOf.call(string), '1', 'number coerces to `"1"`');
54
+ st2.equal(string.a, signal, 'source properties copied');
55
+ st2.end();
56
+ });
57
+
58
+ st.end();
59
+ });
60
+
61
+ t.test('non-object sources', function (st) {
62
+ st.deepEqual(assign({ a: 1 }, null, { b: 2 }), { a: 1, b: 2 }, 'ignores null source');
63
+ st.deepEqual(assign({ a: 1 }, { b: 2 }, undefined), { a: 1, b: 2 }, 'ignores undefined source');
64
+ st.end();
65
+ });
66
+
67
+ t.test('returns the modified target object', function (st) {
68
+ var target = {};
69
+ var returned = assign(target, { a: 1 });
70
+ st.equal(returned, target, 'returned object is the same reference as the target object');
71
+ st.end();
72
+ });
73
+
74
+ t.test('has the right length', function (st) {
75
+ st.equal(assign.length, 2, 'length is 2 => 2 required arguments');
76
+ st.end();
77
+ });
78
+
79
+ t.test('merge two objects', function (st) {
80
+ var target = { a: 1 };
81
+ var returned = assign(target, { b: 2 });
82
+ st.deepEqual(returned, { a: 1, b: 2 }, 'returned object has properties from both');
83
+ st.end();
84
+ });
85
+
86
+ t.test('works with functions', function (st) {
87
+ var target = function () {};
88
+ target.a = 1;
89
+ var returned = assign(target, { b: 2 });
90
+ st.equal(target, returned, 'returned object is target');
91
+ st.equal(returned.a, 1);
92
+ st.equal(returned.b, 2);
93
+ st.end();
94
+ });
95
+
96
+ t.test('works with primitives', function (st) {
97
+ var target = 2;
98
+ var source = { b: 42 };
99
+ var returned = assign(target, source);
100
+ st.equal(Object.prototype.toString.call(returned), '[object Number]', 'returned is object form of number primitive');
101
+ st.equal(Number(returned), target, 'returned and target have same valueOf');
102
+ st.equal(returned.b, source.b);
103
+ st.end();
104
+ });
105
+
106
+ t.test('merge N objects', function (st) {
107
+ var target = { a: 1 };
108
+ var source1 = { b: 2 };
109
+ var source2 = { c: 3 };
110
+ var returned = assign(target, source1, source2);
111
+ st.deepEqual(returned, { a: 1, b: 2, c: 3 }, 'returned object has properties from all sources');
112
+ st.end();
113
+ });
114
+
115
+ t.test('only iterates over own keys', function (st) {
116
+ var Foo = function () {};
117
+ Foo.prototype.bar = true;
118
+ var foo = new Foo();
119
+ foo.baz = true;
120
+ var target = { a: 1 };
121
+ var returned = assign(target, foo);
122
+ st.equal(returned, target, 'returned object is the same reference as the target object');
123
+ st.deepEqual(target, { a: 1, baz: true }, 'returned object has only own properties from both');
124
+ st.end();
125
+ });
126
+
127
+ t.test('includes enumerable symbols, after keys', { skip: !hasSymbols }, function (st) {
128
+ var visited = [];
129
+ var obj = {};
130
+ Object.defineProperty(obj, 'a', { enumerable: true, get: function () { visited.push('a'); return 42; } });
131
+ var symbol = Symbol('enumerable');
132
+ Object.defineProperty(obj, symbol, {
133
+ enumerable: true,
134
+ get: function () { visited.push(symbol); return Infinity; }
135
+ });
136
+ var nonEnumSymbol = Symbol('non-enumerable');
137
+ Object.defineProperty(obj, nonEnumSymbol, {
138
+ enumerable: false,
139
+ get: function () { visited.push(nonEnumSymbol); return -Infinity; }
140
+ });
141
+ var target = assign({}, obj);
142
+ st.deepEqual(visited, ['a', symbol], 'key is visited first, then symbol');
143
+ st.equal(target.a, 42, 'target.a is 42');
144
+ st.equal(target[symbol], Infinity, 'target[symbol] is Infinity');
145
+ st.notEqual(target[nonEnumSymbol], -Infinity, 'target[nonEnumSymbol] is not -Infinity');
146
+ st.end();
147
+ });
148
+
149
+ t.test('does not fail when symbols are not present', function (st) {
150
+ var getSyms;
151
+ if (hasSymbols) {
152
+ getSyms = Object.getOwnPropertySymbols;
153
+ delete Object.getOwnPropertySymbols;
154
+ }
155
+
156
+ var visited = [];
157
+ var obj = {};
158
+ Object.defineProperty(obj, 'a', { enumerable: true, get: function () { visited.push('a'); return 42; } });
159
+ var keys = ['a'];
160
+ if (hasSymbols) {
161
+ var symbol = Symbol('sym');
162
+ Object.defineProperty(obj, symbol, {
163
+ enumerable: true,
164
+ get: function () { visited.push(symbol); return Infinity; }
165
+ });
166
+ keys.push(symbol);
167
+ }
168
+ var target = assign({}, obj);
169
+ st.deepEqual(visited, keys, 'assign visits expected keys');
170
+ st.equal(target.a, 42, 'target.a is 42');
171
+
172
+ if (hasSymbols) {
173
+ st.equal(target[symbol], Infinity);
174
+
175
+ Object.getOwnPropertySymbols = getSyms;
176
+ }
177
+ st.end();
178
+ });
179
+
180
+ t.test('preserves correct property enumeration order', function (st) {
181
+ var str = 'abcdefghijklmnopqrst';
182
+ var letters = {};
183
+ forEach(str.split(''), function (letter) {
184
+ letters[letter] = letter;
185
+ });
186
+
187
+ var n = 5;
188
+ st.comment('run the next test ' + n + ' times');
189
+ var object = assign({}, letters);
190
+ var actual = '';
191
+ for (var k in object) {
192
+ actual += k;
193
+ }
194
+ for (var i = 0; i < n; ++i) {
195
+ st.equal(actual, str, 'property enumeration order should be followed');
196
+ }
197
+ st.end();
198
+ });
199
+
200
+ t.test('checks enumerability and existence, in case of modification during [[Get]]', { skip: !Object.defineProperty }, function (st) {
201
+ var targetBvalue = {};
202
+ var targetCvalue = {};
203
+ var target = { b: targetBvalue, c: targetCvalue };
204
+ var source = {};
205
+ Object.defineProperty(source, 'a', {
206
+ enumerable: true,
207
+ get: function () {
208
+ delete this.b;
209
+ Object.defineProperty(this, 'c', { enumerable: false });
210
+ return 'a';
211
+ }
212
+ });
213
+ var sourceBvalue = {};
214
+ var sourceCvalue = {};
215
+ source.b = sourceBvalue;
216
+ source.c = sourceCvalue;
217
+ var result = assign(target, source);
218
+ st.equal(result, target, 'sanity check: result is === target');
219
+ st.equal(result.b, targetBvalue, 'target key not overwritten by deleted source key');
220
+ st.equal(result.c, targetCvalue, 'target key not overwritten by non-enumerable source key');
221
+
222
+ st.end();
223
+ });
224
+ };
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 17.7.0
4
+ version: 17.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-25 00:00:00.000000000 Z
11
+ date: 2019-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gds-api-adapters
@@ -653,7 +653,6 @@ files:
653
653
  - lib/govuk_publishing_components/presenters/content_item.rb
654
654
  - lib/govuk_publishing_components/presenters/contents_list_helper.rb
655
655
  - lib/govuk_publishing_components/presenters/contextual_navigation.rb
656
- - lib/govuk_publishing_components/presenters/cookie_banner_helper.rb
657
656
  - lib/govuk_publishing_components/presenters/curated_taxonomy_sidebar_links.rb
658
657
  - lib/govuk_publishing_components/presenters/heading_helper.rb
659
658
  - lib/govuk_publishing_components/presenters/highlight_boxes_helper.rb
@@ -5539,6 +5538,22 @@ files:
5539
5538
  - node_modules/object-keys/isArguments.js
5540
5539
  - node_modules/object-keys/package.json
5541
5540
  - node_modules/object-keys/test/index.js
5541
+ - node_modules/object.assign/CHANGELOG.md
5542
+ - node_modules/object.assign/LICENSE
5543
+ - node_modules/object.assign/README.md
5544
+ - node_modules/object.assign/auto.js
5545
+ - node_modules/object.assign/dist/browser.js
5546
+ - node_modules/object.assign/hasSymbols.js
5547
+ - node_modules/object.assign/implementation.js
5548
+ - node_modules/object.assign/index.js
5549
+ - node_modules/object.assign/package.json
5550
+ - node_modules/object.assign/polyfill.js
5551
+ - node_modules/object.assign/shim.js
5552
+ - node_modules/object.assign/test.sh
5553
+ - node_modules/object.assign/test/index.js
5554
+ - node_modules/object.assign/test/native.js
5555
+ - node_modules/object.assign/test/shimmed.js
5556
+ - node_modules/object.assign/test/tests.js
5542
5557
  - node_modules/once/LICENSE
5543
5558
  - node_modules/once/README.md
5544
5559
  - node_modules/once/once.js
@@ -1,23 +0,0 @@
1
- module GovukPublishingComponents
2
- module Presenters
3
- class CookieBannerHelper
4
- attr_reader :local_assigns
5
-
6
- def initialize(local_assigns)
7
- @message = local_assigns[:message]
8
- @new_cookie_banner = local_assigns[:new_cookie_banner]
9
- @local_assigns = local_assigns
10
- end
11
-
12
- def message
13
- return @message if @message.present?
14
-
15
- if @new_cookie_banner
16
- "GOV.UK uses cookies to make the site simpler."
17
- else
18
- 'GOV.UK uses cookies to make the site simpler. <a class="govuk-link" href="/help/cookies" data-module="track-click" data-track-category="cookieBanner" data-track-action="Cookie banner clicked">Find out more about cookies</a> <span class="gem-c-cookie-banner__hide-link">or <a class="govuk-link" href="#" data-hide-cookie-banner="true" data-module="track-click" data-track-category="cookieBanner" data-track-action="Cookie banner hidden">hide this message</a></span>'.html_safe
19
- end
20
- end
21
- end
22
- end
23
- end