Skip to content

Commit aac9094

Browse files
committed
remove deprecated Location.create
1 parent 68ef63c commit aac9094

File tree

10 files changed

+24
-138
lines changed

10 files changed

+24
-138
lines changed

packages/@ember/-internals/routing/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// ES6TODO: Cleanup modules with side-effects below
22
import './lib/ext/controller';
33

4-
export { default as Location } from './lib/location/api';
54
export { default as NoneLocation } from './lib/location/none_location';
65
export { default as HashLocation } from './lib/location/hash_location';
76
export { default as HistoryLocation } from './lib/location/history_location';

packages/@ember/-internals/routing/lib/location/api.ts

-113
This file was deleted.

packages/@ember/-internals/routing/lib/location/auto_location.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import { getOwner } from '@ember/-internals/owner';
44
import { Object as EmberObject } from '@ember/-internals/runtime';
55
import { tryInvoke } from '@ember/-internals/utils';
66
import { assert } from '@ember/debug';
7-
import { EmberLocation, UpdateCallback } from './api';
87
import {
8+
EmberLocation,
99
getFullPath,
1010
getHash,
1111
getPath,
1212
getQuery,
1313
replacePath,
1414
supportsHashChange,
1515
supportsHistory,
16+
UpdateCallback,
1617
} from './util';
17-
1818
/**
1919
@module @ember/routing
2020
*/

packages/@ember/-internals/routing/lib/location/hash_location.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { set } from '@ember/-internals/metal';
22
import { Object as EmberObject } from '@ember/-internals/runtime';
33
import { bind } from '@ember/runloop';
4-
import { EmberLocation, UpdateCallback } from './api';
5-
import { getHash } from './util';
6-
4+
import { EmberLocation, getHash, UpdateCallback } from './util';
75
/**
86
@module @ember/routing
97
*/

packages/@ember/-internals/routing/lib/location/history_location.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { set } from '@ember/-internals/metal';
22
import { Object as EmberObject } from '@ember/-internals/runtime';
3-
import { EmberLocation, UpdateCallback } from './api';
4-
import { getHash } from './util';
3+
import { EmberLocation, getHash, UpdateCallback } from './util';
54

65
/**
76
@module @ember/routing

packages/@ember/-internals/routing/lib/location/none_location.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { set } from '@ember/-internals/metal';
22
import { Object as EmberObject } from '@ember/-internals/runtime';
33
import { assert } from '@ember/debug';
4-
import { EmberLocation, UpdateCallback } from './api';
4+
import { EmberLocation, UpdateCallback } from './util';
55

66
/**
77
@module @ember/routing

packages/@ember/-internals/routing/lib/location/util.ts

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
export interface EmberLocation {
2+
implementation: string;
3+
cancelRouterSetup?: boolean;
4+
getURL(): string;
5+
setURL(url: string): void;
6+
replaceURL?(url: string): void;
7+
onUpdateURL(callback: UpdateCallback): void;
8+
formatURL(url: string): string;
9+
detect?(): void;
10+
initState?(): void;
11+
}
12+
13+
export type UpdateCallback = (url: string) => void;
14+
115
/**
216
@private
317

packages/@ember/-internals/routing/lib/system/router.ts

+5-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import EmberError from '@ember/error';
77
import { assign } from '@ember/polyfills';
88
import { cancel, once, run, scheduleOnce } from '@ember/runloop';
99
import { DEBUG } from '@glimmer/env';
10-
import EmberLocation, { EmberLocation as IEmberLocation } from '../location/api';
10+
import { EmberLocation } from '../location/util';
1111
import { calculateCacheKey, extractRouteArgs, getActiveTargetName, resemblesURL } from '../utils';
1212
import DSL from './dsl';
1313
import Route, {
@@ -121,7 +121,7 @@ const { slice } = Array.prototype;
121121
@public
122122
*/
123123
class EmberRouter extends EmberObject {
124-
location!: string | IEmberLocation;
124+
location!: string | EmberLocation;
125125
rootURL!: string;
126126
_routerMicrolib!: Router<Route>;
127127

@@ -546,7 +546,7 @@ class EmberRouter extends EmberObject {
546546

547547
generate(name: string, ...args: any[]) {
548548
let url = this._routerMicrolib.generate(name, ...args);
549-
return (this.location as IEmberLocation).formatURL(url);
549+
return (this.location as EmberLocation).formatURL(url);
550550
}
551551

552552
/**
@@ -667,17 +667,8 @@ class EmberRouter extends EmberObject {
667667

668668
if ('string' === typeof location && owner) {
669669
let resolvedLocation = owner.lookup(`location:${location}`);
670-
671-
if (resolvedLocation !== undefined) {
672-
location = set(this, 'location', resolvedLocation);
673-
} else {
674-
// Allow for deprecated registration of custom location API's
675-
let options = {
676-
implementation: location,
677-
};
678-
679-
location = set(this, 'location', EmberLocation.create(options));
680-
}
670+
assert(`Location factory with ${location} name is not found`, resolvedLocation !== undefined);
671+
location = set(this, 'location', resolvedLocation);
681672
}
682673

683674
if (location !== null && typeof location === 'object') {

packages/ember/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ Ember.ComponentLookup = views.ComponentLookup;
624624
Ember.EventDispatcher = views.EventDispatcher;
625625

626626
// ****@ember/-internals/routing****
627-
Ember.Location = routing.Location;
628627
Ember.AutoLocation = routing.AutoLocation;
629628
Ember.HashLocation = routing.HashLocation;
630629
Ember.HistoryLocation = routing.HistoryLocation;

packages/ember/tests/reexports_test.js

-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ let allExports = [
319319
['computed.collect', '@ember/object/computed', 'collect'],
320320

321321
// @ember/-internals/routing
322-
['Location', '@ember/-internals/routing'],
323322
['AutoLocation', '@ember/-internals/routing'],
324323
['HashLocation', '@ember/-internals/routing'],
325324
['HistoryLocation', '@ember/-internals/routing'],

0 commit comments

Comments
 (0)