Skip to content

Commit

Permalink
remove deprecated Location.create
Browse files Browse the repository at this point in the history
  • Loading branch information
bekzod committed Jun 20, 2019
1 parent 68ef63c commit 8005411
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 138 deletions.
1 change: 0 additions & 1 deletion packages/@ember/-internals/routing/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// ES6TODO: Cleanup modules with side-effects below
import './lib/ext/controller';

export { default as Location } from './lib/location/api';
export { default as NoneLocation } from './lib/location/none_location';
export { default as HashLocation } from './lib/location/hash_location';
export { default as HistoryLocation } from './lib/location/history_location';
Expand Down
113 changes: 0 additions & 113 deletions packages/@ember/-internals/routing/lib/location/api.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { getOwner } from '@ember/-internals/owner';
import { Object as EmberObject } from '@ember/-internals/runtime';
import { tryInvoke } from '@ember/-internals/utils';
import { assert } from '@ember/debug';
import { EmberLocation, UpdateCallback } from './api';
import {
getFullPath,
getHash,
Expand All @@ -13,8 +12,9 @@ import {
replacePath,
supportsHashChange,
supportsHistory,
EmberLocation,
UpdateCallback
} from './util';

/**
@module @ember/routing
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { set } from '@ember/-internals/metal';
import { Object as EmberObject } from '@ember/-internals/runtime';
import { bind } from '@ember/runloop';
import { EmberLocation, UpdateCallback } from './api';
import { getHash } from './util';

import { getHash, EmberLocation, UpdateCallback } from './util';
/**
@module @ember/routing
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { set } from '@ember/-internals/metal';
import { Object as EmberObject } from '@ember/-internals/runtime';
import { EmberLocation, UpdateCallback } from './api';
import { getHash } from './util';
import { getHash, EmberLocation, UpdateCallback } from './util';

/**
@module @ember/routing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { set } from '@ember/-internals/metal';
import { Object as EmberObject } from '@ember/-internals/runtime';
import { assert } from '@ember/debug';
import { EmberLocation, UpdateCallback } from './api';
import { EmberLocation, UpdateCallback } from './util';

/**
@module @ember/routing
Expand Down
14 changes: 14 additions & 0 deletions packages/@ember/-internals/routing/lib/location/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
export interface EmberLocation {
implementation: string;
cancelRouterSetup?: boolean;
getURL(): string;
setURL(url: string): void;
replaceURL?(url: string): void;
onUpdateURL(callback: UpdateCallback): void;
formatURL(url: string): string;
detect?(): void;
initState?(): void;
}

export type UpdateCallback = (url: string) => void;

/**
@private
Expand Down
19 changes: 5 additions & 14 deletions packages/@ember/-internals/routing/lib/system/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import EmberError from '@ember/error';
import { assign } from '@ember/polyfills';
import { cancel, once, run, scheduleOnce } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';
import EmberLocation, { EmberLocation as IEmberLocation } from '../location/api';
import { EmberLocation } from '../location/utils';
import { calculateCacheKey, extractRouteArgs, getActiveTargetName, resemblesURL } from '../utils';
import DSL from './dsl';
import Route, {
Expand Down Expand Up @@ -121,7 +121,7 @@ const { slice } = Array.prototype;
@public
*/
class EmberRouter extends EmberObject {
location!: string | IEmberLocation;
location!: string | EmberLocation;
rootURL!: string;
_routerMicrolib!: Router<Route>;

Expand Down Expand Up @@ -546,7 +546,7 @@ class EmberRouter extends EmberObject {

generate(name: string, ...args: any[]) {
let url = this._routerMicrolib.generate(name, ...args);
return (this.location as IEmberLocation).formatURL(url);
return (this.location as EmberLocation).formatURL(url);
}

/**
Expand Down Expand Up @@ -667,17 +667,8 @@ class EmberRouter extends EmberObject {

if ('string' === typeof location && owner) {
let resolvedLocation = owner.lookup(`location:${location}`);

if (resolvedLocation !== undefined) {
location = set(this, 'location', resolvedLocation);
} else {
// Allow for deprecated registration of custom location API's
let options = {
implementation: location,
};

location = set(this, 'location', EmberLocation.create(options));
}
assert(`Location factory with ${location} name is not found`, resolvedLocation !== undefined);
location = set(this, 'location', resolvedLocation);
}

if (location !== null && typeof location === 'object') {
Expand Down
1 change: 0 additions & 1 deletion packages/ember/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ Ember.ComponentLookup = views.ComponentLookup;
Ember.EventDispatcher = views.EventDispatcher;

// ****@ember/-internals/routing****
Ember.Location = routing.Location;
Ember.AutoLocation = routing.AutoLocation;
Ember.HashLocation = routing.HashLocation;
Ember.HistoryLocation = routing.HistoryLocation;
Expand Down
1 change: 0 additions & 1 deletion packages/ember/tests/reexports_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ let allExports = [
['computed.collect', '@ember/object/computed', 'collect'],

// @ember/-internals/routing
['Location', '@ember/-internals/routing'],
['AutoLocation', '@ember/-internals/routing'],
['HashLocation', '@ember/-internals/routing'],
['HistoryLocation', '@ember/-internals/routing'],
Expand Down

0 comments on commit 8005411

Please sign in to comment.