Skip to content

Commit b4d0519

Browse files
committed
Remove get/getProperties from EmberObject
1 parent 76b2480 commit b4d0519

File tree

77 files changed

+684
-839
lines changed

Some content is hidden

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

77 files changed

+684
-839
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,4 +389,4 @@
389389
}
390390
},
391391
"packageManager": "[email protected]"
392-
}
392+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ declare const SIGNATURE: unique symbol;
268268
269269
```app/components/my-widget.js
270270
import Component from '@ember/component';
271-
import EmberObject from '@ember/object';
271+
import CoreObject from '@ember/object/core';
272272
273273
export default class extends Component {
274274
classNameBindings = ['messages.empty'];
275275
276-
messages = EmberObject.create({
276+
messages = CoreObject.create({
277277
empty: true
278278
});
279279
}
@@ -867,7 +867,7 @@ class Component<S = unknown>
867867

868868
getAttr(key: string) {
869869
// TODO Intimate API should be deprecated
870-
return this.get(key);
870+
return get(this, key);
871871
}
872872

873873
/**

packages/@ember/-internals/glimmer/tests/integration/application/helper-registration-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { moduleFor, ApplicationTestCase } from 'internal-test-helpers';
22
import Controller from '@ember/controller';
3+
import { get } from '@ember/object';
34
import Service, { service } from '@ember/service';
45
import { Helper, helper } from '@ember/-internals/glimmer';
56

@@ -96,7 +97,7 @@ moduleFor(
9697
nameBuilder;
9798

9899
compute() {
99-
this.get('nameBuilder').build();
100+
get(this, 'nameBuilder').build();
100101
}
101102
}
102103
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ moduleFor(
531531
ComponentClass: class extends Component {
532532
init() {
533533
super.init(...arguments);
534-
this.set('person.name', 'Ben');
534+
set(this, 'person.name', 'Ben');
535535
}
536536
},
537537
template: 'Hi {{this.person.name}} from component',

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

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

3-
import { set } from '@ember/object';
3+
import { get, set } from '@ember/object';
44

55
import { Component } from '../../utils/helpers';
66

@@ -720,11 +720,11 @@ moduleFor(
720720

721721
let bindings = [];
722722

723-
if (this.get('hasFoo')) {
723+
if (get(this, 'hasFoo')) {
724724
bindings.push('foo:data-foo');
725725
}
726726

727-
if (this.get('hasBar')) {
727+
if (get(this, 'hasBar')) {
728728
bindings.push('bar:data-bar');
729729
}
730730

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

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { moduleFor, RenderingTestCase, styles, runTask } from 'internal-test-helpers';
22

3-
import { set, computed } from '@ember/object';
3+
import { get, set, computed } from '@ember/object';
44

55
import { Component, htmlSafe } from '../../utils/helpers';
66

@@ -47,15 +47,15 @@ moduleFor(
4747
firstAttr: 'first attr',
4848
});
4949

50-
assert.equal(instance.get('first'), 'first attr');
50+
assert.equal(get(instance, 'first'), 'first attr');
5151

5252
runTask(() => this.rerender());
5353

54-
assert.equal(instance.get('first'), 'first attr');
54+
assert.equal(get(instance, 'first'), 'first attr');
5555

5656
runTask(() => set(this.context, 'firstAttr', 'second attr'));
5757

58-
assert.equal(instance.get('first'), 'second attr');
58+
assert.equal(get(instance, 'first'), 'second attr');
5959

6060
runTask(() => set(this.context, 'firstAttr', 'first attr'));
6161

@@ -71,7 +71,7 @@ moduleFor(
7171
}
7272

7373
didReceiveAttrs() {
74-
this.set('first', this.get('first').toUpperCase());
74+
set(this, 'first', get(this, 'first').toUpperCase());
7575
}
7676
};
7777
this.registerComponent('foo-bar', {
@@ -81,13 +81,13 @@ moduleFor(
8181

8282
this.render(`{{foo-bar first="first attr"}}`);
8383

84-
assert.equal(instance.get('first'), 'FIRST ATTR', 'component lookup uses local state');
84+
assert.equal(get(instance, 'first'), 'FIRST ATTR', 'component lookup uses local state');
8585
this.assertText('FIRST ATTR');
8686

8787
runTask(() => this.rerender());
8888

8989
assert.equal(
90-
instance.get('first'),
90+
get(instance, 'first'),
9191
'FIRST ATTR',
9292
'component lookup uses local state during rerender'
9393
);
@@ -108,7 +108,7 @@ moduleFor(
108108
}
109109

110110
didReceiveAttrs() {
111-
assert.equal(this.get('woot'), wootVal, 'found attr in didReceiveAttrs');
111+
assert.equal(get(this, 'woot'), wootVal, 'found attr in didReceiveAttrs');
112112
}
113113
};
114114
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
@@ -117,25 +117,25 @@ moduleFor(
117117
woot: wootVal,
118118
});
119119

120-
assert.equal(instance.get('woot'), 'yes', 'component found attr');
120+
assert.equal(get(instance, 'woot'), 'yes', 'component found attr');
121121

122122
runTask(() => this.rerender());
123123

124-
assert.equal(instance.get('woot'), 'yes', 'component found attr after rerender');
124+
assert.equal(get(instance, 'woot'), 'yes', 'component found attr after rerender');
125125

126126
runTask(() => {
127127
wootVal = 'nope';
128128
set(this.context, 'woot', wootVal);
129129
});
130130

131-
assert.equal(instance.get('woot'), 'nope', 'component found attr after attr change');
131+
assert.equal(get(instance, 'woot'), 'nope', 'component found attr after attr change');
132132

133133
runTask(() => {
134134
wootVal = 'yes';
135135
set(this.context, 'woot', wootVal);
136136
});
137137

138-
assert.equal(instance.get('woot'), 'yes', 'component found attr after reset');
138+
assert.equal(get(instance, 'woot'), 'yes', 'component found attr after reset');
139139
}
140140

141141
['@test getAttr() should return the same value as get()'](assert) {
@@ -149,9 +149,9 @@ moduleFor(
149149
}
150150

151151
didReceiveAttrs() {
152-
let rootFirstPositional = this.get('firstPositional');
153-
let rootFirst = this.get('first');
154-
let rootSecond = this.get('second');
152+
let rootFirstPositional = get(this, 'firstPositional');
153+
let rootFirst = get(this, 'first');
154+
let rootSecond = get(this, 'second');
155155
let attrFirstPositional = this.getAttr('firstPositional');
156156
let attrFirst = this.getAttr('first');
157157
let attrSecond = this.getAttr('second');
@@ -178,58 +178,58 @@ moduleFor(
178178
second: 'second',
179179
});
180180

181-
assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value');
182-
assert.equal(instance.get('first'), 'first', 'matches known value');
183-
assert.equal(instance.get('second'), 'second', 'matches known value');
181+
assert.equal(get(instance, 'firstPositional'), 'firstPositional', 'matches known value');
182+
assert.equal(get(instance, 'first'), 'first', 'matches known value');
183+
assert.equal(get(instance, 'second'), 'second', 'matches known value');
184184

185185
runTask(() => this.rerender());
186186

187-
assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value');
188-
assert.equal(instance.get('first'), 'first', 'matches known value');
189-
assert.equal(instance.get('second'), 'second', 'matches known value');
187+
assert.equal(get(instance, 'firstPositional'), 'firstPositional', 'matches known value');
188+
assert.equal(get(instance, 'first'), 'first', 'matches known value');
189+
assert.equal(get(instance, 'second'), 'second', 'matches known value');
190190

191191
runTask(() => {
192192
set(this.context, 'first', 'third');
193193
});
194194

195-
assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value');
196-
assert.equal(instance.get('first'), 'third', 'matches known value');
197-
assert.equal(instance.get('second'), 'second', 'matches known value');
195+
assert.equal(get(instance, 'firstPositional'), 'firstPositional', 'matches known value');
196+
assert.equal(get(instance, 'first'), 'third', 'matches known value');
197+
assert.equal(get(instance, 'second'), 'second', 'matches known value');
198198

199199
runTask(() => {
200200
set(this.context, 'second', 'fourth');
201201
});
202202

203-
assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value');
204-
assert.equal(instance.get('first'), 'third', 'matches known value');
205-
assert.equal(instance.get('second'), 'fourth', 'matches known value');
203+
assert.equal(get(instance, 'firstPositional'), 'firstPositional', 'matches known value');
204+
assert.equal(get(instance, 'first'), 'third', 'matches known value');
205+
assert.equal(get(instance, 'second'), 'fourth', 'matches known value');
206206

207207
runTask(() => {
208208
set(this.context, 'firstPositional', 'fifth');
209209
});
210210

211-
assert.equal(instance.get('firstPositional'), 'fifth', 'matches known value');
212-
assert.equal(instance.get('first'), 'third', 'matches known value');
213-
assert.equal(instance.get('second'), 'fourth', 'matches known value');
211+
assert.equal(get(instance, 'firstPositional'), 'fifth', 'matches known value');
212+
assert.equal(get(instance, 'first'), 'third', 'matches known value');
213+
assert.equal(get(instance, 'second'), 'fourth', 'matches known value');
214214

215215
runTask(() => {
216216
set(this.context, 'firstPositional', 'firstPositional');
217217
set(this.context, 'first', 'first');
218218
set(this.context, 'second', 'second');
219219
});
220220

221-
assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value');
222-
assert.equal(instance.get('first'), 'first', 'matches known value');
223-
assert.equal(instance.get('second'), 'second', 'matches known value');
221+
assert.equal(get(instance, 'firstPositional'), 'firstPositional', 'matches known value');
222+
assert.equal(get(instance, 'first'), 'first', 'matches known value');
223+
assert.equal(get(instance, 'second'), 'second', 'matches known value');
224224
}
225225

226226
['@test bound computed properties can be overridden in extensions, set during init, and passed in as attrs']() {
227227
let FooClass = class extends Component {
228228
attributeBindings = ['style'];
229229
@computed('height', 'color')
230230
get style() {
231-
let height = this.get('height');
232-
let color = this.get('color');
231+
let height = get(this, 'height');
232+
let color = get(this, 'color');
233233
return htmlSafe(`height: ${height}px; background-color: ${color};`);
234234
}
235235
color = 'red';

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

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

3-
import { set, computed } from '@ember/object';
3+
import { get, set, computed } from '@ember/object';
44

55
import { Component } from '../../utils/helpers';
66

@@ -394,11 +394,11 @@ moduleFor(
394394

395395
let bindings = (this.classNameBindings = this.classNameBindings.slice());
396396

397-
if (this.get('bindIsEnabled')) {
397+
if (get(this, 'bindIsEnabled')) {
398398
bindings.push('isEnabled:enabled');
399399
}
400400

401-
if (this.get('bindIsHappy')) {
401+
if (get(this, 'bindIsHappy')) {
402402
bindings.push('isHappy:happy:sad');
403403
}
404404
}

0 commit comments

Comments
 (0)