Skip to content

Commit 7a9a08a

Browse files
committed
Kill Array mixins, some computed macros, REGRESSION in QueryParams!
1 parent 2e2dcf7 commit 7a9a08a

File tree

106 files changed

+306
-9687
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+306
-9687
lines changed

broccoli/amd-compat-entrypoints/ember.debug.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ d('@ember/-internals/runtime/index', emberinternalsRuntimeIndex);
5656
import * as emberinternalsRuntimeLibExtRsvp from '@ember/-internals/runtime/lib/ext/rsvp';
5757
d('@ember/-internals/runtime/lib/ext/rsvp', emberinternalsRuntimeLibExtRsvp);
5858

59-
import * as emberinternalsRuntimeLibMixinsproxy from '@ember/-internals/runtime/lib/mixins/-proxy';
60-
d('@ember/-internals/runtime/lib/mixins/-proxy', emberinternalsRuntimeLibMixinsproxy);
61-
6259
import * as emberinternalsRuntimeLibMixinsActionHandler from '@ember/-internals/runtime/lib/mixins/action_handler';
6360
d(
6461
'@ember/-internals/runtime/lib/mixins/action_handler',
@@ -164,18 +161,12 @@ d('@ember/application/lib/lazy_load', emberApplicationLibLazyLoad);
164161
import * as emberApplicationNamespace from '@ember/application/namespace';
165162
d('@ember/application/namespace', emberApplicationNamespace);
166163

167-
import * as emberArrayinternals from '@ember/array/-internals';
168-
d('@ember/array/-internals', emberArrayinternals);
169-
170164
import * as emberArrayIndex from '@ember/array/index';
171165
d('@ember/array/index', emberArrayIndex);
172166

173167
import * as emberArrayLibMakeArray from '@ember/array/lib/make-array';
174168
d('@ember/array/lib/make-array', emberArrayLibMakeArray);
175169

176-
import * as emberArrayMutable from '@ember/array/mutable';
177-
d('@ember/array/mutable', emberArrayMutable);
178-
179170
import * as emberCanaryFeaturesIndex from '@ember/canary-features/index';
180171
d('@ember/canary-features/index', emberCanaryFeaturesIndex);
181172

@@ -275,9 +266,6 @@ d('@ember/object/internals', emberObjectInternals);
275266
import * as emberObjectLibComputedComputedMacros from '@ember/object/lib/computed/computed_macros';
276267
d('@ember/object/lib/computed/computed_macros', emberObjectLibComputedComputedMacros);
277268

278-
import * as emberObjectLibComputedReduceComputedMacros from '@ember/object/lib/computed/reduce_computed_macros';
279-
d('@ember/object/lib/computed/reduce_computed_macros', emberObjectLibComputedReduceComputedMacros);
280-
281269
import * as emberObjectMixin from '@ember/object/mixin';
282270
d('@ember/object/mixin', emberObjectMixin);
283271

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,14 @@
9999
"ember-cli-typescript-blueprint-polyfill": "^0.1.0",
100100
"ember-cli-version-checker": "^5.1.2",
101101
"ember-router-generator": "^2.0.0",
102+
"ember-tracked-storage-polyfill": "^1.0.0",
102103
"inflection": "^2.0.1",
103104
"route-recognizer": "^0.3.4",
104105
"router_js": "^8.0.5",
105106
"semver": "^7.5.2",
106107
"silent-error": "^1.1.1",
107-
"simple-html-tokenizer": "^0.5.11"
108+
"simple-html-tokenizer": "^0.5.11",
109+
"tracked-built-ins": "^4.0.0"
108110
},
109111
"devDependencies": {
110112
"@aws-sdk/client-s3": "^3.731.0",
@@ -229,11 +231,9 @@
229231
"@ember/application/instance.js": "ember-source/@ember/application/instance.js",
230232
"@ember/application/lib/lazy_load.js": "ember-source/@ember/application/lib/lazy_load.js",
231233
"@ember/application/namespace.js": "ember-source/@ember/application/namespace.js",
232-
"@ember/array/-internals.js": "ember-source/@ember/array/-internals.js",
233234
"@ember/array/index.js": "ember-source/@ember/array/index.js",
234235
"@ember/array/lib/make-array.js": "ember-source/@ember/array/lib/make-array.js",
235236
"@ember/array/make.js": "ember-source/@ember/array/make.js",
236-
"@ember/array/mutable.js": "ember-source/@ember/array/mutable.js",
237237
"@ember/canary-features/index.js": "ember-source/@ember/canary-features/index.js",
238238
"@ember/component/helper.js": "ember-source/@ember/component/helper.js",
239239
"@ember/component/index.js": "ember-source/@ember/component/index.js",
@@ -382,7 +382,8 @@
382382
"ember/version.js": "ember-source/ember/version.js",
383383
"route-recognizer/index.js": "ember-source/route-recognizer/index.js",
384384
"router_js/index.js": "ember-source/router_js/index.js",
385-
"rsvp/index.js": "ember-source/rsvp/index.js"
385+
"rsvp/index.js": "ember-source/rsvp/index.js",
386+
"tracked-built-ins/index.js": "ember-source/tracked-built-ins/index.js"
386387
}
387388
},
388389
"typesVersions": {

packages/@ember/-internals/glimmer/lib/utils/iterator.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import { objectAt } from '@ember/-internals/metal';
2-
import type EmberArray from '@ember/array';
3-
import { isEmberArray } from '@ember/array/-internals';
41
import { isObject } from '@ember/-internals/utils';
52
import type { Nullable } from '@ember/-internals/utility-types';
63
import type { IteratorDelegate } from '@glimmer/reference';
74
import { consumeTag, isTracking, tagFor } from '@glimmer/validator';
85
import { EachInWrapper } from '../helpers/each-in';
9-
import type { NativeArray } from '@ember/array';
106

117
export default function toIterator(iterable: unknown): Nullable<IteratorDelegate> {
128
if (iterable instanceof EachInWrapper) {
@@ -21,7 +17,7 @@ function toEachInIterator(iterable: unknown) {
2117
return null;
2218
}
2319

24-
if (Array.isArray(iterable) || isEmberArray(iterable)) {
20+
if (Array.isArray(iterable)) {
2521
return ObjectIterator.fromIndexable(iterable);
2622
} else if (isNativeIterable(iterable)) {
2723
return MapLikeNativeIterator.from(iterable as Iterable<[unknown, unknown]>);
@@ -39,8 +35,6 @@ function toEachIterator(iterable: unknown) {
3935

4036
if (Array.isArray(iterable)) {
4137
return ArrayIterator.from(iterable);
42-
} else if (isEmberArray(iterable)) {
43-
return EmberArrayIterator.from(iterable);
4438
} else if (isNativeIterable(iterable)) {
4539
return ArrayLikeNativeIterator.from(iterable);
4640
} else if (hasForEach(iterable)) {
@@ -101,20 +95,6 @@ class ArrayIterator extends BoundedIterator {
10195
}
10296
}
10397

104-
class EmberArrayIterator extends BoundedIterator {
105-
static from(iterable: EmberArray<unknown> | NativeArray<unknown>) {
106-
return iterable.length > 0 ? new this(iterable) : null;
107-
}
108-
109-
constructor(private array: EmberArray<unknown> | NativeArray<unknown>) {
110-
super(array.length);
111-
}
112-
113-
valueFor(position: number): unknown {
114-
return objectAt(this.array as any, position);
115-
}
116-
}
117-
11898
class ObjectIterator extends BoundedIterator {
11999
static fromIndexable(obj: Indexable) {
120100
let keys = Object.keys(obj);

packages/@ember/-internals/glimmer/tests/integration/components/contextual-components-test.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { moduleFor, RenderingTestCase, applyMixins, strip, runTask } from 'inter
33

44
import { isEmpty } from '@ember/utils';
55
import { action } from '@ember/object';
6-
import { A as emberA } from '@ember/array';
76

87
import { Component } from '../../utils/helpers';
98

9+
import { tracked } from 'tracked-built-ins';
10+
1011
moduleFor(
1112
'Components test: contextual components',
1213
class extends RenderingTestCase {
@@ -1154,7 +1155,7 @@ moduleFor(
11541155
});
11551156

11561157
this.render('{{component (component "my-link") params=this.allParams}}', {
1157-
allParams: emberA(['a', 'b']),
1158+
allParams: tracked(['a', 'b']),
11581159
});
11591160

11601161
this.assertText('ab');
@@ -1163,23 +1164,23 @@ moduleFor(
11631164

11641165
this.assertText('ab');
11651166

1166-
runTask(() => this.context.get('allParams').pushObject('c'));
1167+
runTask(() => this.context.get('allParams').push('c'));
11671168

11681169
this.assertText('abc');
11691170

1170-
runTask(() => this.context.get('allParams').popObject());
1171+
runTask(() => this.context.get('allParams').pop());
11711172

11721173
this.assertText('ab');
11731174

1174-
runTask(() => this.context.get('allParams').clear());
1175+
runTask(() => this.context.get('allParams').splice(0, 2));
11751176

11761177
this.assertText('');
11771178

1178-
runTask(() => this.context.set('allParams', emberA(['1', '2'])));
1179+
runTask(() => this.context.set('allParams', ['1', '2']));
11791180

11801181
this.assertText('12');
11811182

1182-
runTask(() => this.context.set('allParams', emberA(['a', 'b'])));
1183+
runTask(() => this.context.set('allParams', ['a', 'b']));
11831184

11841185
this.assertText('ab');
11851186
}
@@ -1195,7 +1196,7 @@ moduleFor(
11951196
this.render(
11961197
'{{#let (hash link=(component "my-link")) as |c|}}{{c.link params=this.allParams}}{{/let}}',
11971198
{
1198-
allParams: emberA(['a', 'b']),
1199+
allParams: tracked(['a', 'b']),
11991200
}
12001201
);
12011202

@@ -1205,23 +1206,23 @@ moduleFor(
12051206

12061207
this.assertText('ab');
12071208

1208-
runTask(() => this.context.get('allParams').pushObject('c'));
1209+
runTask(() => this.context.get('allParams').push('c'));
12091210

12101211
this.assertText('abc');
12111212

1212-
runTask(() => this.context.get('allParams').popObject());
1213+
runTask(() => this.context.get('allParams').pop());
12131214

12141215
this.assertText('ab');
12151216

1216-
runTask(() => this.context.get('allParams').clear());
1217+
runTask(() => this.context.get('allParams').splice(0, 3));
12171218

12181219
this.assertText('');
12191220

1220-
runTask(() => this.context.set('allParams', emberA(['1', '2'])));
1221+
runTask(() => this.context.set('allParams', ['1', '2']));
12211222

12221223
this.assertText('12');
12231224

1224-
runTask(() => this.context.set('allParams', emberA(['a', 'b'])));
1225+
runTask(() => this.context.set('allParams', ['a', 'b']));
12251226

12261227
this.assertText('ab');
12271228
}

packages/@ember/-internals/glimmer/tests/integration/components/curly-components-test.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
runLoopSettled,
1010
} from 'internal-test-helpers';
1111

12+
import { tracked as trackedBuiltIn } from 'tracked-built-ins';
13+
1214
import { action } from '@ember/object';
1315
import { run } from '@ember/runloop';
1416
import { DEBUG } from '@glimmer/env';
@@ -17,7 +19,6 @@ import { alias } from '@ember/object/computed';
1719
import { on } from '@ember/object/evented';
1820
import Service, { service } from '@ember/service';
1921
import EmberObject, { set, get, computed, observer } from '@ember/object';
20-
import { A as emberA } from '@ember/array';
2122

2223
import { Component, compile, htmlSafe } from '../../utils/helpers';
2324
import { backtrackingMessageFor } from '../../utils/debug-stack';
@@ -1697,7 +1698,7 @@ moduleFor(
16971698
});
16981699

16991700
this.render('{{sample-component names=this.things}}', {
1700-
things: emberA(['Foo', 4, 'Bar']),
1701+
things: trackedBuiltIn(['Foo', 4, 'Bar']),
17011702
});
17021703

17031704
this.assertText('Foo4Bar');
@@ -1706,19 +1707,19 @@ moduleFor(
17061707

17071708
this.assertText('Foo4Bar');
17081709

1709-
runTask(() => this.context.get('things').pushObject(5));
1710+
runTask(() => this.context.get('things').push(5));
17101711

17111712
this.assertText('Foo4Bar5');
17121713

1713-
runTask(() => this.context.get('things').shiftObject());
1714+
runTask(() => this.context.get('things').shift());
17141715

17151716
this.assertText('4Bar5');
17161717

1717-
runTask(() => this.context.get('things').clear());
1718+
runTask(() => this.context.get('things').splice(0, 3));
17181719

17191720
this.assertText('');
17201721

1721-
runTask(() => this.context.set('things', emberA(['Foo', 4, 'Bar'])));
1722+
runTask(() => this.context.set('things', ['Foo', 4, 'Bar']));
17221723

17231724
this.assertText('Foo4Bar');
17241725
}
@@ -2556,7 +2557,7 @@ moduleFor(
25562557
template: 'Child: {{this.item}}.',
25572558
});
25582559

2559-
let items = emberA(['Tom', 'Dick', 'Harry']);
2560+
let items = trackedBuiltIn(['Tom', 'Dick', 'Harry']);
25602561

25612562
this.render('{{non-block items=this.items}}', { items });
25622563

@@ -2566,15 +2567,15 @@ moduleFor(
25662567

25672568
this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]');
25682569

2569-
runTask(() => this.context.get('items').pushObject('Sergio'));
2570+
runTask(() => this.context.get('items').push('Sergio'));
25702571

25712572
this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.][Child: Sergio.]');
25722573

2573-
runTask(() => this.context.get('items').shiftObject());
2574+
runTask(() => this.context.get('items').shift());
25742575

25752576
this.assertText('In layout. [Child: Dick.][Child: Harry.][Child: Sergio.]');
25762577

2577-
runTask(() => this.context.set('items', emberA(['Tom', 'Dick', 'Harry'])));
2578+
runTask(() => this.context.set('items', ['Tom', 'Dick', 'Harry']));
25782579

25792580
this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]');
25802581
}
@@ -3003,7 +3004,7 @@ moduleFor(
30033004

30043005
init() {
30053006
this._super();
3006-
this.options = emberA([]);
3007+
this.options = [];
30073008
this.value = null;
30083009
},
30093010

@@ -3014,11 +3015,16 @@ moduleFor(
30143015
},
30153016

30163017
registerOption(option) {
3017-
this.get('options').addObject(option);
3018+
if (this.get('options').indexOf(option) === -1) {
3019+
this.get('options').push(option);
3020+
}
30183021
},
30193022

30203023
unregisterOption(option) {
3021-
this.get('options').removeObject(option);
3024+
let index = this.get('options').indexOf(option);
3025+
if (index > -1) {
3026+
this.get('options').splice(index, 1);
3027+
}
30223028

30233029
this.updateValue();
30243030
},

packages/@ember/-internals/glimmer/tests/integration/components/life-cycle-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { classes, moduleFor, RenderingTestCase, runTask, strip } from 'internal-
22

33
import { schedule } from '@ember/runloop';
44
import { set, setProperties } from '@ember/object';
5-
import { A as emberA } from '@ember/array';
65
import { getViewElement, getViewId } from '@ember/-internals/views';
76

87
import { Component } from '../../utils/helpers';
8+
import { tracked } from 'tracked-built-ins';
99

1010
class LifeCycleHooksTest extends RenderingTestCase {
1111
constructor() {
@@ -1460,7 +1460,7 @@ moduleFor(
14601460
template: NestedTemplate,
14611461
});
14621462

1463-
let array = emberA([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]);
1463+
let array = tracked([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]);
14641464

14651465
this.render(
14661466
strip`
@@ -1483,8 +1483,8 @@ moduleFor(
14831483
this.assertText('1AB2AB3AB4AB5AB6AB7AB');
14841484

14851485
runTask(() => {
1486-
array.removeAt(2);
1487-
array.removeAt(2);
1486+
array.splice(2, 1);
1487+
array.splice(2, 1);
14881488
set(this.context, 'model.shouldShow', false);
14891489
});
14901490

packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import {
55
runTask,
66
} from 'internal-test-helpers';
77
import Controller, { inject as injectController } from '@ember/controller';
8-
import { A as emberA } from '@ember/array';
98
import { RSVP } from '@ember/-internals/runtime';
109
import Route from '@ember/routing/route';
1110
import NoneLocation from '@ember/routing/none-location';
1211
import { service } from '@ember/service';
1312
import Engine from '@ember/engine';
1413
import { DEBUG } from '@glimmer/env';
1514
import { compile } from '../../../utils/helpers';
15+
import { tracked } from 'tracked-built-ins';
1616

1717
// IE includes the host name
1818
function normalizeUrl(url) {
@@ -1536,7 +1536,7 @@ moduleFor(
15361536
controller = this;
15371537
}
15381538

1539-
routeNames = emberA(['foo', 'bar', 'rar']);
1539+
routeNames = tracked(['foo', 'bar', 'rar']);
15401540
route1 = 'bar';
15411541
route2 = 'foo';
15421542
}
@@ -1579,7 +1579,7 @@ moduleFor(
15791579

15801580
linksEqual(this.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']);
15811581

1582-
runTask(() => controller.routeNames.shiftObject());
1582+
runTask(() => controller.routeNames.shift());
15831583

15841584
linksEqual(this.$('a'), ['/bar', '/rar', '/bar', '/rar', '/rar', '/foo']);
15851585
}

0 commit comments

Comments
 (0)