Skip to content

Commit 414bdec

Browse files
committed
Remove set/setProperties from EmberObject
1 parent b4d0519 commit 414bdec

Some content is hidden

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

47 files changed

+207
-355
lines changed

packages/@ember/-internals/glimmer/lib/component-managers/curly.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252

5353
import ComponentStateBucket from '../utils/curly-component-state-bucket';
5454
import { processComponentArgs } from '../utils/process-args';
55+
import { setProperties } from '@ember/-internals/metal';
5556

5657
export const ARGS = enumerableSymbol('ARGS');
5758
export const HAS_BLOCK = enumerableSymbol('HAS_BLOCK');
@@ -440,7 +441,7 @@ export default class CurlyComponentManager
440441
bucket.argsRevision = valueForTag(argsTag);
441442

442443
component[IS_DISPATCHING_ATTRS] = true;
443-
component.setProperties(props);
444+
setProperties(component, props);
444445
component[IS_DISPATCHING_ATTRS] = false;
445446

446447
component.trigger('didUpdateAttrs');

packages/@ember/-internals/glimmer/lib/component-managers/mount.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { InternalOwner } from '@ember/-internals/owner';
22
import { generateControllerFactory } from '@ember/routing/-internals';
33
import { assert } from '@ember/debug';
44
import EngineInstance from '@ember/engine/instance';
5+
import { get, set } from '@ember/object';
56
import { associateDestroyableChild } from '@glimmer/destroyable';
67
import type {
78
CapturedArguments,
@@ -95,7 +96,7 @@ class MountManager
9596
let modelRef;
9697

9798
if (args.named.has('model')) {
98-
modelRef = args.named.get('model');
99+
modelRef = get(args.named, 'model') as Reference;
99100
}
100101

101102
if (modelRef === undefined) {
@@ -163,7 +164,7 @@ class MountManager
163164
let { controller, modelRef } = bucket;
164165

165166
if (modelRef !== undefined) {
166-
controller.set('model', valueForRef(modelRef));
167+
set(controller, 'model', valueForRef(modelRef));
167168
}
168169
}
169170
}

packages/@ember/-internals/glimmer/tests/integration/application/debug-render-tree-test.ts

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { ENV } from '@ember/-internals/environment';
99
import { Component, setComponentManager } from '@ember/-internals/glimmer';
1010
import type { InternalOwner } from '@ember/-internals/owner';
11+
import { set } from '@ember/object';
1112
import Route from '@ember/routing/route';
1213
import Controller from '@ember/controller';
1314
import { assert, captureRenderTree } from '@ember/debug';
@@ -313,7 +314,8 @@ if (ENV._DEBUG_RENDER_TREE) {
313314
]);
314315

315316
runTask(() => {
316-
this.controllerFor('application')!.set('engineName', 'bar');
317+
const controller = this.controllerFor('application')!;
318+
set(controller, 'engineName', 'bar');
317319
});
318320

319321
this.assertRenderTree([
@@ -362,7 +364,8 @@ if (ENV._DEBUG_RENDER_TREE) {
362364
]);
363365

364366
runTask(() => {
365-
this.controllerFor('application')!.set('engineName', undefined);
367+
const controller = this.controllerFor('application')!;
368+
set(controller, 'engineName', undefined);
366369
});
367370

368371
this.assertRenderTree([
@@ -396,10 +399,9 @@ if (ENV._DEBUG_RENDER_TREE) {
396399
};
397400

398401
runTask(() => {
399-
this.controllerFor('application')!.setProperties({
400-
showMore: true,
401-
engineModel: model,
402-
});
402+
const controller = this.controllerFor('application')!;
403+
set(controller, 'showMore', true);
404+
set(controller, 'engineModel', model);
403405
});
404406

405407
this.assertRenderTree([
@@ -458,7 +460,8 @@ if (ENV._DEBUG_RENDER_TREE) {
458460
]);
459461

460462
runTask(() => {
461-
this.controllerFor('application')!.set('engineName', 'bar');
463+
const controller = this.controllerFor('application')!;
464+
set(controller, 'engineName', 'bar');
462465
});
463466

464467
this.assertRenderTree([
@@ -569,10 +572,9 @@ if (ENV._DEBUG_RENDER_TREE) {
569572
]);
570573

571574
runTask(() => {
572-
this.controllerFor('application')!.setProperties({
573-
showMore: false,
574-
engineName: undefined,
575-
});
575+
const controller = this.controllerFor('application')!;
576+
set(controller, 'showMore', false);
577+
set(controller, 'engineName', undefined);
576578
});
577579

578580
this.assertRenderTree([
@@ -720,7 +722,7 @@ if (ENV._DEBUG_RENDER_TREE) {
720722
runTask(() => {
721723
let controller = instance!.lookup('controller:application');
722724
assert('Expected an instance of controller', controller instanceof Controller);
723-
controller.set('message', 'World');
725+
set(controller, 'message', 'World');
724726
});
725727

726728
this.assertRenderTree([
@@ -776,7 +778,7 @@ if (ENV._DEBUG_RENDER_TREE) {
776778
runTask(() => {
777779
let controller = instance!.lookup('controller:application');
778780
assert('Expected an instance of controller', controller instanceof Controller);
779-
controller.set('message', undefined);
781+
set(controller, 'message', undefined);
780782
});
781783

782784
this.assertRenderTree([
@@ -870,7 +872,8 @@ if (ENV._DEBUG_RENDER_TREE) {
870872
]);
871873

872874
runTask(() => {
873-
this.controllerFor('application')!.set('showSecond', true);
875+
const controller = this.controllerFor('application')!;
876+
set(controller, 'showSecond', true);
874877
});
875878

876879
this.assertRenderTree([
@@ -895,7 +898,8 @@ if (ENV._DEBUG_RENDER_TREE) {
895898
]);
896899

897900
runTask(() => {
898-
this.controllerFor('application')!.set('showSecond', false);
901+
const controller = this.controllerFor('application')!;
902+
set(controller, 'showSecond', false);
899903
});
900904

901905
this.assertRenderTree([
@@ -943,7 +947,8 @@ if (ENV._DEBUG_RENDER_TREE) {
943947
]);
944948

945949
runTask(() => {
946-
this.controllerFor('application')!.set('showSecond', true);
950+
const controller = this.controllerFor('application')!;
951+
set(controller, 'showSecond', true);
947952
});
948953

949954
this.assertRenderTree([
@@ -968,7 +973,8 @@ if (ENV._DEBUG_RENDER_TREE) {
968973
]);
969974

970975
runTask(() => {
971-
this.controllerFor('application')!.set('showSecond', false);
976+
const controller = this.controllerFor('application')!;
977+
set(controller, 'showSecond', false);
972978
});
973979

974980
this.assertRenderTree([
@@ -1018,7 +1024,8 @@ if (ENV._DEBUG_RENDER_TREE) {
10181024
]);
10191025

10201026
runTask(() => {
1021-
this.controllerFor('application')!.set('showSecond', true);
1027+
const controller = this.controllerFor('application')!;
1028+
set(controller, 'showSecond', true);
10221029
});
10231030

10241031
this.assertRenderTree([
@@ -1043,7 +1050,8 @@ if (ENV._DEBUG_RENDER_TREE) {
10431050
]);
10441051

10451052
runTask(() => {
1046-
this.controllerFor('application')!.set('showSecond', false);
1053+
const controller = this.controllerFor('application')!;
1054+
set(controller, 'showSecond', false);
10471055
});
10481056

10491057
this.assertRenderTree([
@@ -1091,7 +1099,8 @@ if (ENV._DEBUG_RENDER_TREE) {
10911099
]);
10921100

10931101
runTask(() => {
1094-
this.controllerFor('application')!.set('showSecond', true);
1102+
const controller = this.controllerFor('application')!;
1103+
set(controller, 'showSecond', true);
10951104
});
10961105

10971106
this.assertRenderTree([
@@ -1116,7 +1125,8 @@ if (ENV._DEBUG_RENDER_TREE) {
11161125
]);
11171126

11181127
runTask(() => {
1119-
this.controllerFor('application')!.set('showSecond', false);
1128+
const controller = this.controllerFor('application')!;
1129+
set(controller, 'showSecond', false);
11201130
});
11211131

11221132
this.assertRenderTree([
@@ -1176,7 +1186,8 @@ if (ENV._DEBUG_RENDER_TREE) {
11761186
]);
11771187

11781188
runTask(() => {
1179-
this.controllerFor('application')!.set('showSecond', true);
1189+
const controller = this.controllerFor('application')!;
1190+
set(controller, 'showSecond', true);
11801191
});
11811192

11821193
this.assertRenderTree([
@@ -1201,7 +1212,8 @@ if (ENV._DEBUG_RENDER_TREE) {
12011212
]);
12021213

12031214
runTask(() => {
1204-
this.controllerFor('application')!.set('showSecond', false);
1215+
const controller = this.controllerFor('application')!;
1216+
set(controller, 'showSecond', false);
12051217
});
12061218

12071219
this.assertRenderTree([
@@ -1295,7 +1307,7 @@ if (ENV._DEBUG_RENDER_TREE) {
12951307
},
12961308
]);
12971309

1298-
runTask(() => target.set('showSecond', true));
1310+
runTask(() => set(target, 'showSecond', true));
12991311

13001312
const secondModifiers: ExpectedRenderNode['children'] = [
13011313
{
@@ -1366,7 +1378,7 @@ if (ENV._DEBUG_RENDER_TREE) {
13661378
},
13671379
]);
13681380

1369-
runTask(() => target.set('showSecond', false));
1381+
runTask(() => set(target, 'showSecond', false));
13701382

13711383
this.assertRenderTree([
13721384
{
@@ -1462,7 +1474,8 @@ if (ENV._DEBUG_RENDER_TREE) {
14621474
this.assertRenderTree([textareaNode('first', this.element!.firstChild, firstModifiers)]);
14631475

14641476
runTask(() => {
1465-
this.controllerFor('application')!.set('showSecond', true);
1477+
const controller = this.controllerFor('application')!;
1478+
set(controller, 'showSecond', true);
14661479
});
14671480

14681481
const secondModifiers: ExpectedRenderNode['children'] = [
@@ -1519,7 +1532,8 @@ if (ENV._DEBUG_RENDER_TREE) {
15191532
]);
15201533

15211534
runTask(() => {
1522-
this.controllerFor('application')!.set('showSecond', false);
1535+
const controller = this.controllerFor('application')!;
1536+
set(controller, 'showSecond', false);
15231537
});
15241538

15251539
this.assertRenderTree([textareaNode('first', this.element!.firstChild, firstModifiers)]);
@@ -1571,7 +1585,8 @@ if (ENV._DEBUG_RENDER_TREE) {
15711585
]);
15721586

15731587
runTask(() => {
1574-
this.controllerFor('application')!.set('showSecond', true);
1588+
const controller = this.controllerFor('application')!;
1589+
set(controller, 'showSecond', true);
15751590
});
15761591

15771592
const secondModifiers: ExpectedRenderNode['children'] = [
@@ -1608,7 +1623,8 @@ if (ENV._DEBUG_RENDER_TREE) {
16081623
]);
16091624

16101625
runTask(() => {
1611-
this.controllerFor('application')!.set('showSecond', false);
1626+
const controller = this.controllerFor('application')!;
1627+
set(controller, 'showSecond', false);
16121628
});
16131629

16141630
this.assertRenderTree([

packages/@ember/-internals/glimmer/tests/integration/application/hot-reload-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { moduleFor, ApplicationTestCase, strip, runTask } from 'internal-test-helpers';
22

3+
import { set } from '@ember/object';
34
import Service, { service } from '@ember/service';
45
import { Component, Helper } from '@ember/-internals/glimmer';
56

@@ -182,7 +183,7 @@ moduleFor(
182183
tagName = '';
183184
init() {
184185
super.init(...arguments);
185-
this.set('id', id++);
186+
set(this, 'id', id++);
186187
}
187188
},
188189
template: 'x-foo: {{@name}} ({{this.id}})',
@@ -193,7 +194,7 @@ moduleFor(
193194
tagName = '';
194195
init() {
195196
super.init(...arguments);
196-
this.set('id', id++);
197+
set(this, 'id', id++);
197198
}
198199
},
199200
template: 'x-bar ({{this.id}})',

packages/@ember/-internals/glimmer/tests/integration/components/angle-bracket-invocation-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,11 @@ moduleFor(
427427

428428
this.assertText('Hola');
429429

430-
runTask(() => this.context.set('model.bar', 'Hello'));
430+
runTask(() => set(this.context, 'model.bar', 'Hello'));
431431

432432
this.assertText('Hello');
433433

434-
runTask(() => this.context.set('model', { bar: 'Hola' }));
434+
runTask(() => set(this.context, 'model', { bar: 'Hola' }));
435435

436436
this.assertText('Hola');
437437
}
@@ -453,11 +453,11 @@ moduleFor(
453453

454454
this.assertText('Hola');
455455

456-
runTask(() => this.context.set('model.bar', 'Hello'));
456+
runTask(() => set(this.context, 'model.bar', 'Hello'));
457457

458458
this.assertText('Hello');
459459

460-
runTask(() => this.context.set('model', { bar: 'Hola' }));
460+
runTask(() => set(this.context, 'model', { bar: 'Hola' }));
461461

462462
this.assertText('Hola');
463463
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ moduleFor(
408408
this.assertText('Not outer 29');
409409

410410
runTask(() => {
411-
this.context.set('model', {
411+
set(this.context, 'model', {
412412
outerName: 'Outer',
413413
outerAge: 28,
414414
});
@@ -454,7 +454,7 @@ moduleFor(
454454
this.assertText('Inner 29');
455455

456456
runTask(() => {
457-
this.context.set('model', {
457+
set(this.context, 'model', {
458458
outerName: 'Outer',
459459
outerAge: 28,
460460
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ moduleFor(
726726
ComponentClass: class extends Component {
727727
init() {
728728
super.init(...arguments);
729-
this.set('person', {
729+
set(this, 'person', {
730730
name: 'Alex',
731731
toString() {
732732
return `Person (${this.name})`;

0 commit comments

Comments
 (0)