Skip to content

Commit c2167a8

Browse files
committed
Mostly remove reopen
1 parent 0b57bb6 commit c2167a8

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

+904
-1442
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
@@ -97,7 +97,7 @@ function initialize(obj: CoreObject, properties?: unknown) {
9797

9898
assert(
9999
'EmberObject.create no longer supports defining computed ' +
100-
'properties. Define computed properties using extend() or reopen() ' +
100+
'properties. Define computed properties using extend() ' +
101101
'before calling create().',
102102
!isClassicDecorator(value)
103103
);
@@ -313,11 +313,6 @@ class CoreObject {
313313
}
314314
}
315315

316-
reopen(...args: Array<Mixin | Record<string, unknown>>): this {
317-
applyMixin(this, args);
318-
return this;
319-
}
320-
321316
/**
322317
An overridable method called when objects are instantiated. By default,
323318
does nothing unless it is overridden during class definition.
@@ -806,60 +801,6 @@ class CoreObject {
806801
return instance as InstanceType<C> & MergeArray<Args>;
807802
}
808803

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

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

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

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

225221
MyClass.eachComputedProperty(function (name) {
@@ -236,17 +232,12 @@ moduleFor(
236232

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

247238
assert.deepEqual(
248239
list.sort(),
249-
['bar', 'bat', 'baz', 'foo', 'qux'],
240+
['bar', 'baz', 'foo', 'qux'],
250241
'all inherited properties are included'
251242
);
252243
}
@@ -270,10 +261,6 @@ moduleFor(
270261

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

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

279266
list = [];
@@ -282,11 +269,7 @@ moduleFor(
282269
list.push(name);
283270
});
284271

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

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

@@ -298,8 +281,8 @@ moduleFor(
298281

299282
assert.deepEqual(
300283
list.sort(),
301-
['bar', 'foo', 'baz', 'qux'].sort(),
302-
'expected four computed properties'
284+
['bar', 'foo', 'qux'].sort(),
285+
'expected three computed properties'
303286
);
304287
}
305288

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']() {

0 commit comments

Comments
 (0)