Skip to content

Commit b1b0394

Browse files
committed
Remove toStringExtension
1 parent de5610d commit b1b0394

File tree

2 files changed

+4
-44
lines changed

2 files changed

+4
-44
lines changed

packages/@ember/object/core.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,6 @@ import { DEBUG } from '@glimmer/env';
2020
import { destroy, isDestroying, isDestroyed, registerDestructor } from '@glimmer/destroyable';
2121
import { OWNER } from '@glimmer/owner';
2222

23-
interface HasToStringExtension {
24-
toStringExtension: () => void;
25-
}
26-
27-
function hasToStringExtension(val: unknown): val is HasToStringExtension {
28-
return (
29-
typeof val === 'object' &&
30-
val !== null &&
31-
typeof (val as HasToStringExtension).toStringExtension === 'function'
32-
);
33-
}
34-
3523
const wasApplied = new WeakSet();
3624

3725
const initCalled = DEBUG ? new WeakSet() : undefined; // only used in debug builds to enable the proxy trap
@@ -376,27 +364,12 @@ class CoreObject {
376364
student.toString(); //=> "<(subclass of Person):ember1025>"
377365
```
378366
379-
If the method `toStringExtension` is defined, its return value will be
380-
included in the output.
381-
382-
```javascript
383-
const Teacher = Person.extend({
384-
toStringExtension() {
385-
return this.get('fullName');
386-
}
387-
});
388-
teacher = Teacher.create();
389-
teacher.toString(); //=> "<Teacher:ember1026:Tom Dale>"
390-
```
391-
392367
@method toString
393368
@return {String} string representation
394369
@public
395370
*/
396371
toString() {
397-
let extension = hasToStringExtension(this) ? `:${this.toStringExtension()}` : '';
398-
399-
return `<${getFactoryFor(this) || '(unknown)'}:${guidFor(this)}${extension}>`;
372+
return `<${getFactoryFor(this) || '(unknown)'}:${guidFor(this)}>`;
400373
}
401374

402375
/**

packages/@ember/object/tests/toString_test.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,16 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers';
55
moduleFor(
66
'system/object/toString',
77
class extends AbstractTestCase {
8-
['@test toString includes toStringExtension if defined'](assert) {
9-
let Foo = class extends CoreObject {
10-
toStringExtension() {
11-
return 'fooey';
12-
}
13-
};
8+
['@test toString'](assert) {
9+
let Foo = class extends CoreObject {};
1410
let foo = Foo.create();
15-
let Bar = class extends CoreObject {};
16-
let bar = Bar.create();
1711

1812
// simulate these classes being defined on a Namespace
1913
setName(Foo, 'Foo');
20-
setName(Bar, 'Bar');
2114

22-
assert.equal(
23-
bar.toString(),
24-
'<(unknown):' + guidFor(bar) + '>',
25-
'does not include toStringExtension part'
26-
);
2715
assert.equal(
2816
foo.toString(),
29-
'<(unknown):' + guidFor(foo) + ':fooey>',
30-
'Includes toStringExtension result'
17+
'<(unknown):' + guidFor(foo) + '>'
3118
);
3219
}
3320
}

0 commit comments

Comments
 (0)