Skip to content

Commit 77c136d

Browse files
committed
Clean up custom proto code
1 parent feba16b commit 77c136d

File tree

4 files changed

+5
-31
lines changed

4 files changed

+5
-31
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ moduleFor(
15521552

15531553
['@test lifecycle hooks exist on the base class'](assert) {
15541554
// Make sure we get the finalized component prototype
1555-
let prototype = Component.proto();
1555+
let prototype = Component.prototype;
15561556

15571557
assert.equal(typeof prototype.didDestroyElement, 'function', 'didDestroyElement exists');
15581558
assert.equal(typeof prototype.didInsertElement, 'function', 'didInsertElement exists');

packages/@ember/-internals/metal/tests/computed_test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ moduleFor(
3535
}
3636
};
3737

38-
Obj.proto(); // ensure the prototype is "collapsed" / merged
39-
4038
assert.ok(isComputed(Obj.prototype, 'foo'));
4139
}
4240

packages/@ember/-internals/runtime/tests/mixins/accessor_test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ moduleFor(
1717
}
1818
};
1919

20-
// force Base to be finalized so its properties will contain `foo`
21-
Base.proto();
22-
2320
class Child extends Base {
2421
get foo() {
2522
if (value === 'building') {
@@ -30,8 +27,6 @@ moduleFor(
3027
}
3128
}
3229

33-
Child.proto();
34-
3530
let Grandchild = class extends Child {
3631
get foo() {
3732
if (value === 'building') {

packages/@ember/object/core.ts

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

23-
const wasApplied = new WeakSet();
24-
2523
const initCalled = DEBUG ? new WeakSet() : undefined; // only used in debug builds to enable the proxy trap
2624

2725
const destroyCalled = new Set();
@@ -143,9 +141,6 @@ class CoreObject {
143141
constructor(owner?: Owner) {
144142
this[OWNER] = owner;
145143

146-
// prepare prototype...
147-
(this.constructor as typeof CoreObject).proto();
148-
149144
let self = this;
150145

151146
const destroyable = self;
@@ -461,18 +456,6 @@ class CoreObject {
461456
return c !== Function.prototype ? c : undefined;
462457
}
463458

464-
static proto() {
465-
let p = this.prototype;
466-
if (!wasApplied.has(p)) {
467-
wasApplied.add(p);
468-
let parent = this.superclass;
469-
if (parent) {
470-
parent.proto();
471-
}
472-
}
473-
return p;
474-
}
475-
476459
static toString() {
477460
return `<${getFactoryFor(this) || '(unknown)'}:constructor>`;
478461
}
@@ -495,10 +478,9 @@ if (DEBUG) {
495478
*/
496479
CoreObject._onLookup = function injectedPropertyAssertion(debugContainerKey: string) {
497480
let [type] = debugContainerKey.split(':');
498-
let proto = this.proto();
499481

500-
for (let key in proto) {
501-
let desc = descriptorForProperty(proto, key);
482+
for (let key in this.prototype) {
483+
let desc = descriptorForProperty(this.prototype, key);
502484
if (desc && DEBUG_INJECTION_FUNCTIONS.has(desc._getter)) {
503485
assert(
504486
`Defining \`${key}\` as an injected controller property on a non-controller (\`${debugContainerKey}\`) is not allowed.`,
@@ -518,12 +500,11 @@ if (DEBUG) {
518500
*/
519501
CoreObject._lazyInjections = function () {
520502
let injections: Record<string, { namespace: unknown; source: unknown; specifier: string }> = {};
521-
let proto = this.proto();
522503
let key;
523504
let desc;
524505

525-
for (key in proto) {
526-
desc = descriptorForProperty(proto, key);
506+
for (key in this.prototype) {
507+
desc = descriptorForProperty(this.prototype, key);
527508
if (desc && DEBUG_INJECTION_FUNCTIONS.has(desc._getter)) {
528509
let { namespace, source, type, name } = DEBUG_INJECTION_FUNCTIONS.get(desc._getter);
529510

0 commit comments

Comments
 (0)