ember-source 3.28.5 → 4.0.0-beta.10
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.
- package/CHANGELOG.md +113 -10
- package/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js +1 -1
- package/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +1 -1
- package/blueprints/component-test/qunit-files/__root__/__testType__/__path__/__test__.js +3 -3
- package/blueprints/helper-test/index.js +4 -22
- package/blueprints/helper-test/mocha-0.12-files/__root__/__testType__/__collection__/__name__-test.js +1 -13
- package/blueprints/helper-test/mocha-files/__root__/__testType__/__collection__/__name__-test.js +0 -13
- package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -12
- package/blueprints/helper-test/qunit-files/__root__/__testType__/__collection__/__name__-test.js +2 -13
- package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -14
- package/blueprints/initializer/files/__root__/initializers/__name__.js +0 -1
- package/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js +0 -1
- package/build-metadata.json +3 -3
- package/dist/dependencies/@glimmer/manager.js +19 -98
- package/dist/dependencies/@glimmer/opcode-compiler.js +9 -146
- package/dist/dependencies/@glimmer/runtime.js +1 -55
- package/dist/dependencies/@glimmer/validator.js +19 -51
- package/dist/ember-template-compiler.js +3692 -5667
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +12 -560
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +4357 -12470
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/bootstrap/index.js +2 -55
- package/dist/packages/@ember/-internals/container/index.js +35 -206
- package/dist/packages/@ember/-internals/environment/index.js +3 -46
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +7 -0
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +1 -2
- package/dist/packages/@ember/-internals/glimmer/index.js +4774 -7035
- package/dist/packages/@ember/-internals/meta/lib/meta.js +2 -50
- package/dist/packages/@ember/-internals/metal/index.js +785 -1109
- package/dist/packages/@ember/-internals/overrides/index.js +1 -3
- package/dist/packages/@ember/-internals/owner/index.js +1 -19
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +1 -51
- package/dist/packages/@ember/-internals/routing/lib/location/hash_location.js +1 -0
- package/dist/packages/@ember/-internals/routing/lib/location/history_location.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/location/none_location.js +0 -7
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +34 -2
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +2 -3
- package/dist/packages/@ember/-internals/routing/lib/system/dsl.js +5 -6
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +192 -652
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +119 -248
- package/dist/packages/@ember/-internals/routing/lib/system/router_state.js +1 -2
- package/dist/packages/@ember/-internals/routing/lib/utils.js +1 -2
- package/dist/packages/@ember/-internals/runtime/index.js +1 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +4 -175
- package/dist/packages/@ember/-internals/runtime/lib/mixins/observable.js +1 -18
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +3 -43
- package/dist/packages/@ember/-internals/runtime/lib/system/array_proxy.js +8 -15
- package/dist/packages/@ember/-internals/runtime/lib/system/core_object.js +10 -141
- package/dist/packages/@ember/-internals/utils/index.js +3 -59
- package/dist/packages/@ember/-internals/views/index.js +0 -2
- package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +1 -121
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +4 -40
- package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +115 -190
- package/dist/packages/@ember/-internals/views/lib/views/states/destroying.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/has_element.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/in_dom.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/pre_render.js +1 -2
- package/dist/packages/@ember/application/instance.js +3 -25
- package/dist/packages/@ember/application/lib/application.js +14 -32
- package/dist/packages/@ember/canary-features/index.js +5 -6
- package/dist/packages/@ember/component/index.js +1 -1
- package/dist/packages/@ember/component/template-only.js +2 -0
- package/dist/packages/@ember/debug/lib/deprecate.js +7 -41
- package/dist/packages/@ember/deprecated-features/index.js +1 -14
- package/dist/packages/@ember/engine/index.js +3 -17
- package/dist/packages/@ember/engine/instance.js +0 -4
- package/dist/packages/@ember/helper/index.js +12 -4
- package/dist/packages/@ember/object/index.js +3 -101
- package/dist/packages/@ember/object/internals.js +0 -1
- package/dist/packages/@ember/object/lib/computed/computed_macros.js +12 -384
- package/dist/packages/@ember/object/lib/computed/reduce_computed_macros.js +9 -360
- package/dist/packages/@ember/polyfills/index.js +1 -6
- package/dist/packages/@ember/polyfills/lib/assign.js +12 -28
- package/dist/packages/@ember/routing/index.js +1 -1
- package/dist/packages/@ember/runloop/index.js +1 -83
- package/dist/packages/@ember/string/index.js +1 -206
- package/dist/packages/@ember/utils/index.js +0 -1
- package/dist/packages/ember/index.js +17 -180
- package/dist/packages/ember/version.js +1 -1
- package/dist/packages/ember-testing/index.js +0 -2
- package/dist/packages/ember-testing/lib/helpers.js +0 -12
- package/dist/packages/ember-testing/lib/setup_for_testing.js +0 -10
- package/docs/data.json +1637 -3659
- package/lib/index.js +14 -59
- package/lib/overrides.js +0 -61
- package/lib/transforms/inject-babel-helpers.js +1 -3
- package/package.json +27 -23
- package/dist/packages/@ember/-internals/console/index.js +0 -190
- package/dist/packages/@ember/-internals/runtime/lib/copy.js +0 -119
- package/dist/packages/@ember/-internals/runtime/lib/ext/function.js +0 -155
- package/dist/packages/@ember/-internals/runtime/lib/mixins/copyable.js +0 -31
- package/dist/packages/@ember/-internals/views/lib/mixins/text_support.js +0 -357
- package/dist/packages/@ember/-internals/views/lib/system/jquery.js +0 -26
- package/dist/packages/@ember/-internals/views/lib/system/jquery_event_deprecation.js +0 -60
- package/dist/packages/@ember/application/deprecations.js +0 -25
- package/dist/packages/@ember/application/globals-resolver.js +0 -434
- package/dist/packages/@ember/application/resolver.js +0 -1
- package/dist/packages/@ember/component/checkbox.js +0 -17
- package/dist/packages/@ember/component/text-area.js +0 -17
- package/dist/packages/@ember/component/text-field.js +0 -17
- package/dist/packages/@ember/polyfills/lib/merge.js +0 -50
- package/dist/packages/@ember/routing/link-component.js +0 -17
- package/dist/packages/ember-testing/lib/events.js +0 -102
- package/dist/packages/ember-testing/lib/helpers/-is-form-control.js +0 -19
- package/dist/packages/ember-testing/lib/helpers/click.js +0 -32
- package/dist/packages/ember-testing/lib/helpers/fill_in.js +0 -47
- package/dist/packages/ember-testing/lib/helpers/find.js +0 -40
- package/dist/packages/ember-testing/lib/helpers/find_with_assert.js +0 -37
- package/dist/packages/ember-testing/lib/helpers/key_event.js +0 -37
- package/dist/packages/ember-testing/lib/helpers/trigger_event.js +0 -61
- package/dist/packages/ember-testing/lib/support.js +0 -57
- package/dist/packages/jquery/index.js +0 -2
|
@@ -7,7 +7,7 @@ import { computed, autoComputed, get, isElementDescriptor } from '@ember/-intern
|
|
|
7
7
|
import { compare, isArray, A as emberA, uniqBy as uniqByArray } from '@ember/-internals/runtime';
|
|
8
8
|
|
|
9
9
|
function reduceMacro(dependentKey, callback, initialValue, name) {
|
|
10
|
-
assert(`Dependent key passed to
|
|
10
|
+
assert(`Dependent key passed to \`${name}\` computed macro shouldn't contain brace expanding pattern.`, !/[[\]{}]/g.test(dependentKey));
|
|
11
11
|
return computed(`${dependentKey}.[]`, function () {
|
|
12
12
|
let arr = get(this, dependentKey);
|
|
13
13
|
|
|
@@ -42,7 +42,7 @@ function arrayMacro(dependentKey, additionalDependentKeys, callback) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function multiArrayMacro(_dependentKeys, callback, name) {
|
|
45
|
-
assert(`Dependent keys passed to
|
|
45
|
+
assert(`Dependent keys passed to \`${name}\` computed macro shouldn't contain brace expanding pattern.`, _dependentKeys.every(dependentKey => !/[[\]{}]/g.test(dependentKey)));
|
|
46
46
|
|
|
47
47
|
let dependentKeys = _dependentKeys.map(key => `${key}.[]`);
|
|
48
48
|
|
|
@@ -69,23 +69,6 @@ function multiArrayMacro(_dependentKeys, callback, name) {
|
|
|
69
69
|
invoice.total; // 13.49
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
Classic Class Example:
|
|
73
|
-
|
|
74
|
-
```javascript
|
|
75
|
-
import EmberObject from '@ember/object';
|
|
76
|
-
import { sum } from '@ember/object/computed';
|
|
77
|
-
|
|
78
|
-
let Invoice = EmberObject.extend({
|
|
79
|
-
lineItems: [1.00, 2.50, 9.99],
|
|
80
|
-
|
|
81
|
-
total: sum('lineItems')
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
let invoice = Invoice.create();
|
|
85
|
-
|
|
86
|
-
invoice.total; // 13.49
|
|
87
|
-
```
|
|
88
|
-
|
|
89
72
|
@method sum
|
|
90
73
|
@for @ember/object/computed
|
|
91
74
|
@static
|
|
@@ -143,42 +126,6 @@ export function sum(dependentKey) {
|
|
|
143
126
|
lordByron.maxChildAge; // 8
|
|
144
127
|
```
|
|
145
128
|
|
|
146
|
-
Classic Class Example:
|
|
147
|
-
|
|
148
|
-
```javascript
|
|
149
|
-
import EmberObject, { set } from '@ember/object';
|
|
150
|
-
import { mapBy, max } from '@ember/object/computed';
|
|
151
|
-
|
|
152
|
-
let Person = EmberObject.extend({
|
|
153
|
-
childAges: mapBy('children', 'age'),
|
|
154
|
-
maxChildAge: max('childAges')
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
let lordByron = Person.create({ children: [] });
|
|
158
|
-
|
|
159
|
-
lordByron.maxChildAge; // -Infinity
|
|
160
|
-
|
|
161
|
-
set(lordByron, 'children', [
|
|
162
|
-
{
|
|
163
|
-
name: 'Augusta Ada Byron',
|
|
164
|
-
age: 7
|
|
165
|
-
}
|
|
166
|
-
]);
|
|
167
|
-
lordByron.maxChildAge; // 7
|
|
168
|
-
|
|
169
|
-
set(lordByron, 'children', [
|
|
170
|
-
...lordByron.children,
|
|
171
|
-
{
|
|
172
|
-
name: 'Allegra Byron',
|
|
173
|
-
age: 5
|
|
174
|
-
}, {
|
|
175
|
-
name: 'Elizabeth Medora Leigh',
|
|
176
|
-
age: 8
|
|
177
|
-
}
|
|
178
|
-
]);
|
|
179
|
-
lordByron.maxChildAge; // 8
|
|
180
|
-
```
|
|
181
|
-
|
|
182
129
|
If the types of the arguments are not numbers, they will be converted to
|
|
183
130
|
numbers and the type of the return value will always be `Number`. For example,
|
|
184
131
|
the max of a list of Date objects will be the highest timestamp as a `Number`.
|
|
@@ -239,42 +186,6 @@ export function max(dependentKey) {
|
|
|
239
186
|
lordByron.minChildAge; // 5
|
|
240
187
|
```
|
|
241
188
|
|
|
242
|
-
Classic Class Example:
|
|
243
|
-
|
|
244
|
-
```javascript
|
|
245
|
-
import EmberObject, { set } from '@ember/object';
|
|
246
|
-
import { mapBy, min } from '@ember/object/computed';
|
|
247
|
-
|
|
248
|
-
let Person = EmberObject.extend({
|
|
249
|
-
childAges: mapBy('children', 'age'),
|
|
250
|
-
minChildAge: min('childAges')
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
let lordByron = Person.create({ children: [] });
|
|
254
|
-
|
|
255
|
-
lordByron.minChildAge; // Infinity
|
|
256
|
-
|
|
257
|
-
set(lordByron, 'children', [
|
|
258
|
-
{
|
|
259
|
-
name: 'Augusta Ada Byron',
|
|
260
|
-
age: 7
|
|
261
|
-
}
|
|
262
|
-
]);
|
|
263
|
-
lordByron.minChildAge; // 7
|
|
264
|
-
|
|
265
|
-
set(lordByron, 'children', [
|
|
266
|
-
...lordByron.children,
|
|
267
|
-
{
|
|
268
|
-
name: 'Allegra Byron',
|
|
269
|
-
age: 5
|
|
270
|
-
}, {
|
|
271
|
-
name: 'Elizabeth Medora Leigh',
|
|
272
|
-
age: 8
|
|
273
|
-
}
|
|
274
|
-
]);
|
|
275
|
-
lordByron.minChildAge; // 5
|
|
276
|
-
```
|
|
277
|
-
|
|
278
189
|
If the types of the arguments are not numbers, they will be converted to
|
|
279
190
|
numbers and the type of the return value will always be `Number`. For example,
|
|
280
191
|
the min of a list of Date objects will be the lowest timestamp as a `Number`.
|
|
@@ -325,25 +236,6 @@ export function min(dependentKey) {
|
|
|
325
236
|
hamster.excitingChores; // ['CLEAN!', 'WRITE MORE UNIT TESTS!']
|
|
326
237
|
```
|
|
327
238
|
|
|
328
|
-
Classic Class Example:
|
|
329
|
-
|
|
330
|
-
```javascript
|
|
331
|
-
import EmberObject from '@ember/object';
|
|
332
|
-
import { map } from '@ember/object/computed';
|
|
333
|
-
|
|
334
|
-
let Hamster = EmberObject.extend({
|
|
335
|
-
excitingChores: map('chores', function(chore, index) {
|
|
336
|
-
return `${chore.toUpperCase()}!`;
|
|
337
|
-
})
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
let hamster = Hamster.create({
|
|
341
|
-
chores: ['clean', 'write more unit tests']
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
hamster.excitingChores; // ['CLEAN!', 'WRITE MORE UNIT TESTS!']
|
|
345
|
-
```
|
|
346
|
-
|
|
347
239
|
You can optionally pass an array of additional dependent keys as the second
|
|
348
240
|
parameter to the macro, if your map function relies on any external values:
|
|
349
241
|
|
|
@@ -441,41 +333,6 @@ export function map(dependentKey, additionalDependentKeys, callback) {
|
|
|
441
333
|
lordByron.childAges; // [7, 5, 8]
|
|
442
334
|
```
|
|
443
335
|
|
|
444
|
-
Classic Class Example:
|
|
445
|
-
|
|
446
|
-
```javascript
|
|
447
|
-
import EmberObject, { set } from '@ember/object';
|
|
448
|
-
import { mapBy } from '@ember/object/computed';
|
|
449
|
-
|
|
450
|
-
let Person = EmberObject.extend({
|
|
451
|
-
childAges: mapBy('children', 'age')
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
let lordByron = Person.create({ children: [] });
|
|
455
|
-
|
|
456
|
-
lordByron.childAges; // []
|
|
457
|
-
|
|
458
|
-
set(lordByron, 'children', [
|
|
459
|
-
{
|
|
460
|
-
name: 'Augusta Ada Byron',
|
|
461
|
-
age: 7
|
|
462
|
-
}
|
|
463
|
-
]);
|
|
464
|
-
lordByron.childAges; // [7]
|
|
465
|
-
|
|
466
|
-
set(lordByron, 'children', [
|
|
467
|
-
...lordByron.children,
|
|
468
|
-
{
|
|
469
|
-
name: 'Allegra Byron',
|
|
470
|
-
age: 5
|
|
471
|
-
}, {
|
|
472
|
-
name: 'Elizabeth Medora Leigh',
|
|
473
|
-
age: 8
|
|
474
|
-
}
|
|
475
|
-
]);
|
|
476
|
-
lordByron.childAges; // [7, 5, 8]
|
|
477
|
-
```
|
|
478
|
-
|
|
479
336
|
@method mapBy
|
|
480
337
|
@for @ember/object/computed
|
|
481
338
|
@static
|
|
@@ -487,8 +344,8 @@ export function map(dependentKey, additionalDependentKeys, callback) {
|
|
|
487
344
|
|
|
488
345
|
export function mapBy(dependentKey, propertyKey) {
|
|
489
346
|
assert('You attempted to use @mapBy as a decorator directly, but it requires `dependentKey` and `propertyKey` parameters', !isElementDescriptor(Array.prototype.slice.call(arguments)));
|
|
490
|
-
assert('`
|
|
491
|
-
assert(`Dependent key passed to \`
|
|
347
|
+
assert('`mapBy` computed macro expects a property string for its second argument, ' + 'perhaps you meant to use "map"', typeof propertyKey === 'string');
|
|
348
|
+
assert(`Dependent key passed to \`mapBy\` computed macro shouldn't contain brace expanding pattern.`, !/[[\]{}]/g.test(dependentKey));
|
|
492
349
|
return map(`${dependentKey}.@each.${propertyKey}`, item => get(item, propertyKey));
|
|
493
350
|
}
|
|
494
351
|
/**
|
|
@@ -529,29 +386,6 @@ export function mapBy(dependentKey, propertyKey) {
|
|
|
529
386
|
hamster.remainingChores; // [{name: 'write more unit tests', done: false}]
|
|
530
387
|
```
|
|
531
388
|
|
|
532
|
-
Classic Class Example:
|
|
533
|
-
|
|
534
|
-
```javascript
|
|
535
|
-
import EmberObject from '@ember/object';
|
|
536
|
-
import { filter } from '@ember/object/computed';
|
|
537
|
-
|
|
538
|
-
let Hamster = EmberObject.extend({
|
|
539
|
-
remainingChores: filter('chores', function(chore, index, array) {
|
|
540
|
-
return !chore.done;
|
|
541
|
-
})
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
let hamster = Hamster.create({
|
|
545
|
-
chores: [
|
|
546
|
-
{ name: 'cook', done: true },
|
|
547
|
-
{ name: 'clean', done: true },
|
|
548
|
-
{ name: 'write more unit tests', done: false }
|
|
549
|
-
]
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
hamster.remainingChores; // [{name: 'write more unit tests', done: false}]
|
|
553
|
-
```
|
|
554
|
-
|
|
555
389
|
You can also use `@each.property` in your dependent key, the callback will
|
|
556
390
|
still use the underlying array:
|
|
557
391
|
|
|
@@ -660,27 +494,6 @@ export function filter(dependentKey, additionalDependentKeys, callback) {
|
|
|
660
494
|
hamster.remainingChores; // [{ name: 'write more unit tests', done: false }]
|
|
661
495
|
```
|
|
662
496
|
|
|
663
|
-
Classic Class Example:
|
|
664
|
-
|
|
665
|
-
```javascript
|
|
666
|
-
import EmberObject from '@ember/object';
|
|
667
|
-
import { filterBy } from '@ember/object/computed';
|
|
668
|
-
|
|
669
|
-
let Hamster = EmberObject.extend({
|
|
670
|
-
remainingChores: filterBy('chores', 'done', false)
|
|
671
|
-
});
|
|
672
|
-
|
|
673
|
-
let hamster = Hamster.create({
|
|
674
|
-
chores: [
|
|
675
|
-
{ name: 'cook', done: true },
|
|
676
|
-
{ name: 'clean', done: true },
|
|
677
|
-
{ name: 'write more unit tests', done: false }
|
|
678
|
-
]
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
hamster.remainingChores; // [{ name: 'write more unit tests', done: false }]
|
|
682
|
-
```
|
|
683
|
-
|
|
684
497
|
@method filterBy
|
|
685
498
|
@for @ember/object/computed
|
|
686
499
|
@static
|
|
@@ -693,7 +506,7 @@ export function filter(dependentKey, additionalDependentKeys, callback) {
|
|
|
693
506
|
|
|
694
507
|
export function filterBy(dependentKey, propertyKey, value) {
|
|
695
508
|
assert('You attempted to use @filterBy as a decorator directly, but it requires atleast `dependentKey` and `propertyKey` parameters', !isElementDescriptor(Array.prototype.slice.call(arguments)));
|
|
696
|
-
assert(`Dependent key passed to \`
|
|
509
|
+
assert(`Dependent key passed to \`filterBy\` computed macro shouldn't contain brace expanding pattern.`, !/[[\]{}]/g.test(dependentKey));
|
|
697
510
|
let callback;
|
|
698
511
|
|
|
699
512
|
if (arguments.length === 2) {
|
|
@@ -732,28 +545,6 @@ export function filterBy(dependentKey, propertyKey, value) {
|
|
|
732
545
|
hamster.uniqueFruits; // ['banana', 'grape', 'kale']
|
|
733
546
|
```
|
|
734
547
|
|
|
735
|
-
Classic Class Example:
|
|
736
|
-
|
|
737
|
-
```javascript
|
|
738
|
-
import EmberObject from '@ember/object';
|
|
739
|
-
import { uniq } from '@ember/object/computed';
|
|
740
|
-
|
|
741
|
-
let Hamster = EmberObject.extend({
|
|
742
|
-
uniqueFruits: uniq('fruits')
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
let hamster = Hamster.create({
|
|
746
|
-
fruits: [
|
|
747
|
-
'banana',
|
|
748
|
-
'grape',
|
|
749
|
-
'kale',
|
|
750
|
-
'banana'
|
|
751
|
-
]
|
|
752
|
-
});
|
|
753
|
-
|
|
754
|
-
hamster.uniqueFruits; // ['banana', 'grape', 'kale']
|
|
755
|
-
```
|
|
756
|
-
|
|
757
548
|
@method uniq
|
|
758
549
|
@for @ember/object/computed
|
|
759
550
|
@static
|
|
@@ -811,28 +602,6 @@ export function uniq(...args) {
|
|
|
811
602
|
hamster.uniqueFruits; // [ { id: 1, 'banana' }, { id: 2, 'grape' }, { id: 3, 'peach' }]
|
|
812
603
|
```
|
|
813
604
|
|
|
814
|
-
Classic Class Example:
|
|
815
|
-
|
|
816
|
-
```javascript
|
|
817
|
-
import EmberObject from '@ember/object';
|
|
818
|
-
import { uniqBy } from '@ember/object/computed';
|
|
819
|
-
|
|
820
|
-
let Hamster = EmberObject.extend({
|
|
821
|
-
uniqueFruits: uniqBy('fruits', 'id')
|
|
822
|
-
});
|
|
823
|
-
|
|
824
|
-
let hamster = Hamster.create({
|
|
825
|
-
fruits: [
|
|
826
|
-
{ id: 1, 'banana' },
|
|
827
|
-
{ id: 2, 'grape' },
|
|
828
|
-
{ id: 3, 'peach' },
|
|
829
|
-
{ id: 1, 'banana' }
|
|
830
|
-
]
|
|
831
|
-
});
|
|
832
|
-
|
|
833
|
-
hamster.uniqueFruits; // [ { id: 1, 'banana' }, { id: 2, 'grape' }, { id: 3, 'peach' }]
|
|
834
|
-
```
|
|
835
|
-
|
|
836
605
|
@method uniqBy
|
|
837
606
|
@for @ember/object/computed
|
|
838
607
|
@static
|
|
@@ -845,7 +614,7 @@ export function uniq(...args) {
|
|
|
845
614
|
|
|
846
615
|
export function uniqBy(dependentKey, propertyKey) {
|
|
847
616
|
assert('You attempted to use @uniqBy as a decorator directly, but it requires `dependentKey` and `propertyKey` parameters', !isElementDescriptor(Array.prototype.slice.call(arguments)));
|
|
848
|
-
assert(`Dependent key passed to \`
|
|
617
|
+
assert(`Dependent key passed to \`uniqBy\` computed macro shouldn't contain brace expanding pattern.`, !/[[\]{}]/g.test(dependentKey));
|
|
849
618
|
return computed(`${dependentKey}.[]`, function () {
|
|
850
619
|
let list = get(this, dependentKey);
|
|
851
620
|
return isArray(list) ? uniqByArray(list, propertyKey) : emberA();
|
|
@@ -888,34 +657,6 @@ export function uniqBy(dependentKey, propertyKey) {
|
|
|
888
657
|
hamster.uniqueFruits; // ['banana', 'grape', 'kale', 'tomato', 'carrot', 'lettuce']
|
|
889
658
|
```
|
|
890
659
|
|
|
891
|
-
Classic Class Example:
|
|
892
|
-
|
|
893
|
-
```javascript
|
|
894
|
-
import EmberObject from '@ember/object';
|
|
895
|
-
import { union } from '@ember/object/computed';
|
|
896
|
-
|
|
897
|
-
let Hamster = EmberObject.extend({
|
|
898
|
-
uniqueFruits: union('fruits', 'vegetables')
|
|
899
|
-
});
|
|
900
|
-
|
|
901
|
-
let hamster = Hamster.create({
|
|
902
|
-
fruits: [
|
|
903
|
-
'banana',
|
|
904
|
-
'grape',
|
|
905
|
-
'kale',
|
|
906
|
-
'banana',
|
|
907
|
-
'tomato'
|
|
908
|
-
],
|
|
909
|
-
vegetables: [
|
|
910
|
-
'tomato',
|
|
911
|
-
'carrot',
|
|
912
|
-
'lettuce'
|
|
913
|
-
]
|
|
914
|
-
});
|
|
915
|
-
|
|
916
|
-
hamster.uniqueFruits; // ['banana', 'grape', 'kale', 'tomato', 'carrot', 'lettuce']
|
|
917
|
-
```
|
|
918
|
-
|
|
919
660
|
@method union
|
|
920
661
|
@for @ember/object/computed
|
|
921
662
|
@static
|
|
@@ -953,24 +694,6 @@ export let union = uniq;
|
|
|
953
694
|
groups.friendsInCommon; // ['William King', 'Mary Somerville']
|
|
954
695
|
```
|
|
955
696
|
|
|
956
|
-
Classic Class Example:
|
|
957
|
-
|
|
958
|
-
```javascript
|
|
959
|
-
import EmberObject from '@ember/object';
|
|
960
|
-
import { intersect } from '@ember/object/computed';
|
|
961
|
-
|
|
962
|
-
let FriendGroups = EmberObject.extend({
|
|
963
|
-
friendsInCommon: intersect('adaFriends', 'charlesFriends')
|
|
964
|
-
});
|
|
965
|
-
|
|
966
|
-
let groups = FriendGroups.create({
|
|
967
|
-
adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'],
|
|
968
|
-
charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock']
|
|
969
|
-
});
|
|
970
|
-
|
|
971
|
-
groups.friendsInCommon; // ['William King', 'Mary Somerville']
|
|
972
|
-
```
|
|
973
|
-
|
|
974
697
|
@method intersect
|
|
975
698
|
@for @ember/object/computed
|
|
976
699
|
@static
|
|
@@ -1043,31 +766,6 @@ export function intersect(...args) {
|
|
|
1043
766
|
hamster.wants; // ['banana']
|
|
1044
767
|
```
|
|
1045
768
|
|
|
1046
|
-
Classic Class Example:
|
|
1047
|
-
|
|
1048
|
-
```javascript
|
|
1049
|
-
import EmberObject from '@ember/object';
|
|
1050
|
-
import { setDiff } from '@ember/object/computed';
|
|
1051
|
-
|
|
1052
|
-
let Hamster = EmberObject.extend({
|
|
1053
|
-
wants: setDiff('likes', 'fruits')
|
|
1054
|
-
});
|
|
1055
|
-
|
|
1056
|
-
let hamster = Hamster.create({
|
|
1057
|
-
likes: [
|
|
1058
|
-
'banana',
|
|
1059
|
-
'grape',
|
|
1060
|
-
'kale'
|
|
1061
|
-
],
|
|
1062
|
-
fruits: [
|
|
1063
|
-
'grape',
|
|
1064
|
-
'kale',
|
|
1065
|
-
]
|
|
1066
|
-
});
|
|
1067
|
-
|
|
1068
|
-
hamster.wants; // ['banana']
|
|
1069
|
-
```
|
|
1070
|
-
|
|
1071
769
|
@method setDiff
|
|
1072
770
|
@for @ember/object/computed
|
|
1073
771
|
@static
|
|
@@ -1080,8 +778,8 @@ export function intersect(...args) {
|
|
|
1080
778
|
|
|
1081
779
|
export function setDiff(setAProperty, setBProperty) {
|
|
1082
780
|
assert('You attempted to use @setDiff as a decorator directly, but it requires atleast one dependent key parameter', !isElementDescriptor(Array.prototype.slice.call(arguments)));
|
|
1083
|
-
assert('`
|
|
1084
|
-
assert(`Dependent keys passed to \`
|
|
781
|
+
assert('`setDiff` computed macro requires exactly two dependent arrays.', arguments.length === 2);
|
|
782
|
+
assert(`Dependent keys passed to \`setDiff\` computed macro shouldn't contain brace expanding pattern.`, !/[[\]{}]/g.test(setAProperty) && !/[[\]{}]/g.test(setBProperty));
|
|
1085
783
|
return computed(`${setAProperty}.[]`, `${setBProperty}.[]`, function () {
|
|
1086
784
|
let setA = get(this, setAProperty);
|
|
1087
785
|
let setB = get(this, setBProperty);
|
|
@@ -1120,25 +818,6 @@ export function setDiff(setAProperty, setBProperty) {
|
|
|
1120
818
|
hamster.clothes; // ['Camp Hat', 'Camp Shirt']
|
|
1121
819
|
```
|
|
1122
820
|
|
|
1123
|
-
Classic Class Example:
|
|
1124
|
-
|
|
1125
|
-
```javascript
|
|
1126
|
-
import EmberObject, { set } from '@ember/object';
|
|
1127
|
-
import { collect } from '@ember/object/computed';
|
|
1128
|
-
|
|
1129
|
-
let Hamster = EmberObject.extend({
|
|
1130
|
-
clothes: collect('hat', 'shirt')
|
|
1131
|
-
});
|
|
1132
|
-
|
|
1133
|
-
let hamster = Hamster.create();
|
|
1134
|
-
|
|
1135
|
-
hamster.clothes; // [null, null]
|
|
1136
|
-
|
|
1137
|
-
set(hamster, 'hat', 'Camp Hat');
|
|
1138
|
-
set(hamster, 'shirt', 'Camp Shirt');
|
|
1139
|
-
hamster.clothes; // ['Camp Hat', 'Camp Shirt']
|
|
1140
|
-
```
|
|
1141
|
-
|
|
1142
821
|
@method collect
|
|
1143
822
|
@for @ember/object/computed
|
|
1144
823
|
@static
|
|
@@ -1218,36 +897,6 @@ export function collect(...dependentKeys) {
|
|
|
1218
897
|
todoList.priorityTodos; // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }]
|
|
1219
898
|
```
|
|
1220
899
|
|
|
1221
|
-
Classic Class Example:
|
|
1222
|
-
|
|
1223
|
-
```javascript
|
|
1224
|
-
import EmberObject from '@ember/object';
|
|
1225
|
-
import { sort } from '@ember/object/computed';
|
|
1226
|
-
|
|
1227
|
-
let ToDoList = EmberObject.extend({
|
|
1228
|
-
// using a custom sort function
|
|
1229
|
-
priorityTodos: sort('todos', function(a, b){
|
|
1230
|
-
if (a.priority > b.priority) {
|
|
1231
|
-
return 1;
|
|
1232
|
-
} else if (a.priority < b.priority) {
|
|
1233
|
-
return -1;
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
return 0;
|
|
1237
|
-
})
|
|
1238
|
-
});
|
|
1239
|
-
|
|
1240
|
-
let todoList = ToDoList.create({
|
|
1241
|
-
todos: [
|
|
1242
|
-
{ name: 'Unit Test', priority: 2 },
|
|
1243
|
-
{ name: 'Documentation', priority: 3 },
|
|
1244
|
-
{ name: 'Release', priority: 1 }
|
|
1245
|
-
]
|
|
1246
|
-
});
|
|
1247
|
-
|
|
1248
|
-
todoList.priorityTodos; // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }]
|
|
1249
|
-
```
|
|
1250
|
-
|
|
1251
900
|
You can also optionally pass an array of additional dependent keys as the
|
|
1252
901
|
second parameter, if your sort function is dependent on additional values that
|
|
1253
902
|
could changes:
|
|
@@ -1342,7 +991,7 @@ export function sort(itemsKey, additionalDependentKeys, sortDefinition) {
|
|
|
1342
991
|
argumentsValid = typeof itemsKey === 'string' && Array.isArray(additionalDependentKeys) && typeof sortDefinition === 'function';
|
|
1343
992
|
}
|
|
1344
993
|
|
|
1345
|
-
assert('`
|
|
994
|
+
assert('The `sort` computed macro can either be used with an array of sort properties or with a sort function. If used with an array of sort properties, it must receive exactly two arguments: the key of the array to sort, and the key of the array of sort properties. If used with a sort function, it may receive up to three arguments: the key of the array to sort, an optional additional array of dependent keys for the computed property, and the sort function.', argumentsValid);
|
|
1346
995
|
}
|
|
1347
996
|
|
|
1348
997
|
if (sortDefinition === undefined && !Array.isArray(additionalDependentKeys)) {
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { default as deprecatedMerge } from './lib/merge';
|
|
3
|
-
let merge = MERGE ? deprecatedMerge : undefined; // Export `assignPolyfill` for testing
|
|
4
|
-
|
|
5
|
-
export { default as assign, assign as assignPolyfill } from './lib/assign';
|
|
6
|
-
export { merge };
|
|
1
|
+
export { assign } from './lib/assign';
|
|
7
2
|
export const hasPropertyAccessors = true;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
@module @ember/polyfills
|
|
3
|
-
*/
|
|
4
|
-
|
|
1
|
+
import { deprecate } from '@ember/debug';
|
|
5
2
|
/**
|
|
6
3
|
Copy properties from a source object to a target object. Source arguments remain unchanged.
|
|
7
4
|
|
|
@@ -23,29 +20,16 @@
|
|
|
23
20
|
@public
|
|
24
21
|
@static
|
|
25
22
|
*/
|
|
26
|
-
export function assign(target) {
|
|
27
|
-
for (let i = 1; i < arguments.length; i++) {
|
|
28
|
-
let arg = arguments[i];
|
|
29
|
-
|
|
30
|
-
if (!arg) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let updates = Object.keys(arg);
|
|
35
23
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
export function assign(target, ...rest) {
|
|
25
|
+
deprecate('Use of `assign` has been deprecated. Please use `Object.assign` or the spread operator instead.', false, {
|
|
26
|
+
id: 'ember-polyfills.deprecate-assign',
|
|
27
|
+
until: '5.0.0',
|
|
28
|
+
url: 'https://deprecations.emberjs.com/v4.x/#toc_ember-polyfills-deprecate-assign',
|
|
29
|
+
for: 'ember-source',
|
|
30
|
+
since: {
|
|
31
|
+
enabled: '4.0.0'
|
|
39
32
|
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} // Note: We use the bracket notation so
|
|
44
|
-
// that the babel plugin does not
|
|
45
|
-
// transform it.
|
|
46
|
-
// https://www.npmjs.com/package/babel-plugin-transform-object-assign
|
|
47
|
-
|
|
48
|
-
const {
|
|
49
|
-
assign: _assign
|
|
50
|
-
} = Object;
|
|
51
|
-
export default _assign || assign;
|
|
33
|
+
});
|
|
34
|
+
return Object.assign(target, ...rest);
|
|
35
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { LinkTo } from '@ember/-internals/glimmer';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { assert, deprecate } from '@ember/debug';
|
|
1
|
+
import { assert } from '@ember/debug';
|
|
3
2
|
import { onErrorTarget } from '@ember/-internals/error-handling';
|
|
4
3
|
import { flushAsyncObservers } from '@ember/-internals/metal';
|
|
5
|
-
import { onRunloopDotAccess } from '@ember/-internals/overrides';
|
|
6
4
|
import Backburner from 'backburner';
|
|
7
5
|
let currentRunLoop = null;
|
|
8
6
|
export function _getCurrentRunLoop() {
|
|
@@ -727,84 +725,4 @@ export function debounce() {
|
|
|
727
725
|
|
|
728
726
|
export function throttle() {
|
|
729
727
|
return _backburner.throttle(...arguments);
|
|
730
|
-
}
|
|
731
|
-
export let _deprecatedGlobalGetCurrentRunLoop; // eslint-disable-next-line no-undef
|
|
732
|
-
|
|
733
|
-
if (DEBUG) {
|
|
734
|
-
let defaultHandler = (dotKey, importKey, module) => {
|
|
735
|
-
return `Using \`${dotKey}\` has been deprecated. Instead, import the value directly from ${module}:\n\n import { ${importKey} } from '${module}';`;
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
let handler = onRunloopDotAccess || defaultHandler;
|
|
739
|
-
|
|
740
|
-
let defineDeprecatedRunloopFunc = (key, func) => {
|
|
741
|
-
Object.defineProperty(run, key, {
|
|
742
|
-
get() {
|
|
743
|
-
let message = handler(`run.${key}`, key, '@ember/runloop');
|
|
744
|
-
deprecate(message, message === null, {
|
|
745
|
-
id: 'deprecated-run-loop-and-computed-dot-access',
|
|
746
|
-
until: '4.0.0',
|
|
747
|
-
for: 'ember-source',
|
|
748
|
-
since: {
|
|
749
|
-
enabled: '3.27.0'
|
|
750
|
-
}
|
|
751
|
-
});
|
|
752
|
-
return func;
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
});
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
_deprecatedGlobalGetCurrentRunLoop = () => {
|
|
759
|
-
let message = handler('run.currentRunLoop', 'getCurrentRunLoop', '@ember/runloop');
|
|
760
|
-
deprecate(message, message === null, {
|
|
761
|
-
id: 'deprecated-run-loop-and-computed-dot-access',
|
|
762
|
-
until: '4.0.0',
|
|
763
|
-
for: 'ember-source',
|
|
764
|
-
since: {
|
|
765
|
-
enabled: '3.27.0'
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
return _getCurrentRunLoop();
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
defineDeprecatedRunloopFunc('backburner', _backburner);
|
|
772
|
-
defineDeprecatedRunloopFunc('begin', begin);
|
|
773
|
-
defineDeprecatedRunloopFunc('bind', bind);
|
|
774
|
-
defineDeprecatedRunloopFunc('cancel', cancel);
|
|
775
|
-
defineDeprecatedRunloopFunc('debounce', debounce);
|
|
776
|
-
defineDeprecatedRunloopFunc('end', end);
|
|
777
|
-
defineDeprecatedRunloopFunc('hasScheduledTimers', _hasScheduledTimers);
|
|
778
|
-
defineDeprecatedRunloopFunc('join', join);
|
|
779
|
-
defineDeprecatedRunloopFunc('later', later);
|
|
780
|
-
defineDeprecatedRunloopFunc('next', next);
|
|
781
|
-
defineDeprecatedRunloopFunc('once', once);
|
|
782
|
-
defineDeprecatedRunloopFunc('schedule', schedule);
|
|
783
|
-
defineDeprecatedRunloopFunc('scheduleOnce', scheduleOnce);
|
|
784
|
-
defineDeprecatedRunloopFunc('throttle', throttle);
|
|
785
|
-
defineDeprecatedRunloopFunc('cancelTimers', _cancelTimers);
|
|
786
|
-
Object.defineProperty(run, 'currentRunLoop', {
|
|
787
|
-
get: _deprecatedGlobalGetCurrentRunLoop,
|
|
788
|
-
enumerable: false
|
|
789
|
-
});
|
|
790
|
-
} else {
|
|
791
|
-
run.backburner = _backburner;
|
|
792
|
-
run.begin = begin;
|
|
793
|
-
run.bind = bind;
|
|
794
|
-
run.cancel = cancel;
|
|
795
|
-
run.debounce = debounce;
|
|
796
|
-
run.end = end;
|
|
797
|
-
run.hasScheduledTimers = _hasScheduledTimers;
|
|
798
|
-
run.join = join;
|
|
799
|
-
run.later = later;
|
|
800
|
-
run.next = next;
|
|
801
|
-
run.once = once;
|
|
802
|
-
run.schedule = schedule;
|
|
803
|
-
run.scheduleOnce = scheduleOnce;
|
|
804
|
-
run.throttle = throttle;
|
|
805
|
-
run.cancelTimers = _cancelTimers;
|
|
806
|
-
Object.defineProperty(run, 'currentRunLoop', {
|
|
807
|
-
get: _getCurrentRunLoop,
|
|
808
|
-
enumerable: false
|
|
809
|
-
});
|
|
810
728
|
}
|