Skip to content

Commit 4989d24

Browse files
committed
Mostly remove reopen
1 parent 6c47098 commit 4989d24

Some content is hidden

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

46 files changed

+903
-1429
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88

99
import { Component } from '@ember/-internals/glimmer';
1010
import Route from '@ember/routing/route';
11+
import EmberRouter from '@ember/routing/router';
1112
import { RSVP } from '@ember/-internals/runtime';
1213
import Controller from '@ember/controller';
1314
import Engine from '@ember/engine';
@@ -17,14 +18,16 @@ import { compile } from '../../utils/helpers';
1718
import { setComponentTemplate } from '@glimmer/manager';
1819
import { templateOnlyComponent } from '@glimmer/runtime';
1920

21+
const originalSetupRouter = EmberRouter.prototype.setupRouter;
22+
2023
moduleFor(
2124
'Application test: engine rendering',
2225
class extends ApplicationTestCase {
2326
get routerOptions() {
2427
return {
2528
location: 'none',
2629
setupRouter() {
27-
this._super(...arguments);
30+
originalSetupRouter.call(this, ...arguments);
2831
let getRoute = this._routerMicrolib.getRoute;
2932
this._enginePromises = Object.create(null);
3033
this._resolvedEngines = Object.create(null);

packages/@ember/-internals/meta/lib/meta.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ export class Meta {
481481
1. A meta has been flattened (listener has been called)
482482
2. The meta is a prototype meta with children who have inherited its
483483
listeners
484-
3. A new listener is subsequently added to the meta (e.g. via `.reopen()`)
485484
486485
This is a very rare occurrence, so while the counter is global it shouldn't
487486
be updated very often in practice.

packages/@ember/-internals/meta/tests/listeners_test.js

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -140,67 +140,6 @@ moduleFor(
140140
}
141141
}
142142

143-
['@test reopen after flatten'](assert) {
144-
if (!DEBUG) {
145-
assert.expect(0);
146-
return;
147-
}
148-
149-
// Ensure counter is zeroed
150-
counters.reopensAfterFlatten = 0;
151-
152-
class Class1 {}
153-
let class1Meta = meta(Class1.prototype);
154-
class1Meta.addToListeners('hello', null, 'm', 0);
155-
156-
let instance1 = new Class1();
157-
let m1 = meta(instance1);
158-
159-
class Class2 {}
160-
let class2Meta = meta(Class2.prototype);
161-
class2Meta.addToListeners('hello', null, 'm', 0);
162-
163-
let instance2 = new Class2();
164-
let m2 = meta(instance2);
165-
166-
m1.matchingListeners('hello');
167-
m2.matchingListeners('hello');
168-
169-
assert.equal(counters.reopensAfterFlatten, 0, 'no reopen calls yet');
170-
171-
m1.addToListeners('world', null, 'm', 0);
172-
m2.addToListeners('world', null, 'm', 0);
173-
m1.matchingListeners('world');
174-
m2.matchingListeners('world');
175-
176-
assert.equal(counters.reopensAfterFlatten, 1, 'reopen calls after invalidating parent cache');
177-
178-
m1.addToListeners('world', null, 'm', 0);
179-
m2.addToListeners('world', null, 'm', 0);
180-
m1.matchingListeners('world');
181-
m2.matchingListeners('world');
182-
183-
assert.equal(counters.reopensAfterFlatten, 1, 'no reopen calls after mutating leaf nodes');
184-
185-
class1Meta.removeFromListeners('hello', null, 'm');
186-
class2Meta.removeFromListeners('hello', null, 'm');
187-
m1.matchingListeners('hello');
188-
m2.matchingListeners('hello');
189-
190-
assert.equal(counters.reopensAfterFlatten, 2, 'one reopen call after mutating parents');
191-
192-
class1Meta.addToListeners('hello', null, 'm', 0);
193-
m1.matchingListeners('hello');
194-
class2Meta.addToListeners('hello', null, 'm', 0);
195-
m2.matchingListeners('hello');
196-
197-
assert.equal(
198-
counters.reopensAfterFlatten,
199-
3,
200-
'one reopen call after mutating parents and flattening out of order'
201-
);
202-
}
203-
204143
'@test removed listeners are removed from the underlying structure GH#1112213'(assert) {
205144
// this is using private API to confirm the underlying data structure is properly maintained
206145
// and should be changed to match the data structure as needed

packages/@ember/-internals/metal/lib/observer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function resumeObserverDeactivation() {
153153
}
154154

155155
/**
156-
* Primarily used for cases where we are redefining a class, e.g. mixins/reopen
156+
* Primarily used for cases where we are redefining a class, e.g. mixins
157157
* being applied later. Revalidates all the observers, resetting their tags.
158158
*
159159
* @private

packages/@ember/application/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,6 @@ class Application extends Engine {
354354
...
355355
});
356356
357-
App.Router.reopen({
358-
location: 'none'
359-
});
360-
361357
App.Router.map({
362358
...
363359
});
@@ -388,6 +384,7 @@ class Application extends Engine {
388384
@default true
389385
@private
390386
*/
387+
// TODO: We should kill this
391388
declare _globalsMode: boolean;
392389

393390
/**

packages/@ember/application/tests/readiness_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ moduleFor(
3434
_document = _document;
3535

3636
ready() {
37-
this._super();
37+
super.ready();
3838
readyWasCalled++;
3939
}
4040
};

packages/@ember/debug/index.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -236,19 +236,6 @@ if (DEBUG) {
236236
freely added for documentation and debugging purposes without worries of
237237
incuring any performance penalty.
238238
239-
```javascript
240-
import Component from '@ember/component';
241-
import { runInDebug } from '@ember/debug';
242-
243-
runInDebug(() => {
244-
Component.reopen({
245-
didInsertElement() {
246-
console.log("I'm happy");
247-
}
248-
});
249-
});
250-
```
251-
252239
@method runInDebug
253240
@for @ember/debug
254241
@static

packages/@ember/object/core.ts

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function initialize(obj: CoreObject, properties?: unknown) {
9696

9797
assert(
9898
'EmberObject.create no longer supports defining computed ' +
99-
'properties. Define computed properties using extend() or reopen() ' +
99+
'properties. Define computed properties using extend() ' +
100100
'before calling create().',
101101
!isClassicDecorator(value)
102102
);
@@ -307,11 +307,6 @@ class CoreObject {
307307
}
308308
}
309309

310-
reopen(...args: Array<Mixin | Record<string, unknown>>): this {
311-
applyMixin(this, args);
312-
return this;
313-
}
314-
315310
/**
316311
An overridable method called when objects are instantiated. By default,
317312
does nothing unless it is overridden during class definition.
@@ -800,60 +795,6 @@ class CoreObject {
800795
return instance as InstanceType<C> & MergeArray<Args>;
801796
}
802797

803-
/**
804-
Augments a constructor's prototype with additional
805-
properties and functions:
806-
807-
```javascript
808-
import EmberObject from '@ember/object';
809-
810-
const MyObject = EmberObject.extend({
811-
name: 'an object'
812-
});
813-
814-
o = MyObject.create();
815-
o.get('name'); // 'an object'
816-
817-
MyObject.reopen({
818-
say(msg) {
819-
console.log(msg);
820-
}
821-
});
822-
823-
o2 = MyObject.create();
824-
o2.say('hello'); // logs "hello"
825-
826-
o.say('goodbye'); // logs "goodbye"
827-
```
828-
829-
To add functions and properties to the constructor itself,
830-
see `reopenClass`
831-
832-
@method reopen
833-
@for @ember/object
834-
@static
835-
@public
836-
*/
837-
static reopen<C extends typeof CoreObject>(this: C, ...args: any[]): C {
838-
this.willReopen();
839-
reopen.apply(this.PrototypeMixin, args);
840-
return this;
841-
}
842-
843-
static willReopen() {
844-
let p = this.prototype;
845-
if (wasApplied.has(p)) {
846-
wasApplied.delete(p);
847-
848-
// If the base mixin already exists and was applied, create a new mixin to
849-
// make sure that it gets properly applied. Reusing the same mixin after
850-
// the first `proto` call will cause it to get skipped.
851-
if (prototypeMixinMap.has(this)) {
852-
prototypeMixinMap.set(this, Mixin.create(this.PrototypeMixin));
853-
}
854-
}
855-
}
856-
857798
/**
858799
Augments a constructor's own properties and functions:
859800
@@ -906,10 +847,6 @@ class CoreObject {
906847
Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda`
907848
variables. They are only valid on `Person`.
908849
909-
To add functions and properties to instances of
910-
a constructor by extending the constructor's prototype
911-
see `reopen`
912-
913850
@method reopenClass
914851
@for @ember/object
915852
@static

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ moduleFor(
215215
baz: computed(function () {}),
216216
});
217217

218-
SubClass.reopen({
219-
bat: computed(function () {}).meta({ iAmBat: true }),
220-
});
221-
222218
let list = [];
223219

224220
MyClass.eachComputedProperty(function (name) {
@@ -235,17 +231,12 @@ moduleFor(
235231

236232
SubClass.eachComputedProperty(function (name, meta) {
237233
list.push(name);
238-
239-
if (name === 'bat') {
240-
assert.deepEqual(meta, { iAmBat: true });
241-
} else {
242-
assert.deepEqual(meta, {});
243-
}
234+
assert.deepEqual(meta, {});
244235
});
245236

246237
assert.deepEqual(
247238
list.sort(),
248-
['bar', 'bat', 'baz', 'foo', 'qux'],
239+
['bar', 'baz', 'foo', 'qux'],
249240
'all inherited properties are included'
250241
);
251242
}
@@ -269,10 +260,6 @@ moduleFor(
269260

270261
assert.deepEqual(list.sort(), ['bar', 'foo'].sort(), 'expected two computed properties');
271262

272-
MyClass.reopen({
273-
baz: computed(K),
274-
});
275-
276263
MyClass.create().destroy(); // force apply mixins
277264

278265
list = [];
@@ -281,11 +268,7 @@ moduleFor(
281268
list.push(name);
282269
});
283270

284-
assert.deepEqual(
285-
list.sort(),
286-
['bar', 'foo', 'baz'].sort(),
287-
'expected three computed properties'
288-
);
271+
assert.deepEqual(list.sort(), ['bar', 'foo'].sort(), 'expected two computed properties');
289272

290273
defineProperty(MyClass.prototype, 'qux', computed(K));
291274

@@ -297,8 +280,8 @@ moduleFor(
297280

298281
assert.deepEqual(
299282
list.sort(),
300-
['bar', 'foo', 'baz', 'qux'].sort(),
301-
'expected four computed properties'
283+
['bar', 'foo', 'qux'].sort(),
284+
'expected three computed properties'
302285
);
303286
}
304287

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ moduleFor(
183183
EmberObject.create({
184184
foo: computed(function () {}),
185185
});
186-
}, 'EmberObject.create no longer supports defining computed properties. Define computed properties using extend() or reopen() before calling create().');
186+
}, 'EmberObject.create no longer supports defining computed properties. Define computed properties using extend() before calling create().');
187187
}
188188

189189
['@test throws if you try to call _super in a method']() {

packages/@ember/object/tests/es-compatibility-test.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,6 @@ moduleFor(
415415
// Only string listeners are allowed for prototypes
416416
addListener(B.prototype, 'someEvent', null, 'onSomeEvent');
417417

418-
B.reopen({
419-
init() {
420-
calls.push('reopen init before _super');
421-
this._super(...arguments);
422-
calls.push('reopen init after _super');
423-
},
424-
});
425-
426418
let C = class extends B {
427419
init() {
428420
calls.push('C init before _super');
@@ -476,15 +468,13 @@ moduleFor(
476468
assert.deepEqual(calls, [
477469
'D init before super.init',
478470
'C init before _super',
479-
'reopen init before _super',
480471
'B init before super.init',
481472
'Mixin2 init before _super',
482473
'Mixin1 init before _super',
483474
'A init',
484475
'Mixin1 init after _super',
485476
'Mixin2 init after _super',
486477
'B init after super.init',
487-
'reopen init after _super',
488478
'C init after _super',
489479
'D init after super.init',
490480
]);

0 commit comments

Comments
 (0)