Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename last handlerInfo references to routeInfo #17136

Merged
merged 1 commit into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/@ember/-internals/routing/lib/services/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ RoutingService.reopen({
currentPath: readOnly('router.currentPath'),
});

function numberOfContextsAcceptedByHandler(handler: any, handlerInfos: any[]) {
function numberOfContextsAcceptedByHandler(handlerName: string, handlerInfos: any[]) {
let req = 0;
for (let i = 0; i < handlerInfos.length; i++) {
req += handlerInfos[i].names.length;
if (handlerInfos[i].handler === handler) {
if (handlerInfos[i].handler === handlerName) {
break;
}
}
Expand Down
54 changes: 27 additions & 27 deletions packages/@ember/-internals/routing/lib/system/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1061,11 +1061,11 @@ class EmberRouter extends EmberObject {

@private
@method _getQPMeta
@param {RouteInfo} handlerInfo
@param {RouteInfo} routeInfo
@return {Object}
*/
_getQPMeta(handlerInfo: PrivateRouteInfo) {
let route = handlerInfo.route;
_getQPMeta(routeInfo: PrivateRouteInfo) {
let route = routeInfo.route;
return route && get(route, '_qp');
}

Expand All @@ -1079,8 +1079,8 @@ class EmberRouter extends EmberObject {
@return {Object}
*/
_queryParamsFor(routeInfos: PrivateRouteInfo[]) {
let handlerInfoLength = routeInfos.length;
let leafRouteName = routeInfos[handlerInfoLength - 1].name;
let routeInfoLength = routeInfos.length;
let leafRouteName = routeInfos[routeInfoLength - 1].name;
let cached = this._qpCache[leafRouteName];
if (cached !== undefined) {
return cached;
Expand All @@ -1095,7 +1095,7 @@ class EmberRouter extends EmberObject {
let urlKey;
let qpOther;

for (let i = 0; i < handlerInfoLength; ++i) {
for (let i = 0; i < routeInfoLength; ++i) {
qpMeta = this._getQPMeta(routeInfos[i]);

if (!qpMeta) {
Expand Down Expand Up @@ -1350,19 +1350,19 @@ class EmberRouter extends EmberObject {

@private
@param {Route} originRoute
@param {Array<HandlerInfo>} routeInfos
@param {Array<RouteInfo>} routeInfos
@param {Function} callback
@return {Void}
*/
function forEachRouteAbove(
routeInfos: PrivateRouteInfo[],
callback: (route: Route, handlerInfo: PrivateRouteInfo) => boolean
callback: (route: Route, routeInfo: PrivateRouteInfo) => boolean
) {
for (let i = routeInfos.length - 1; i >= 0; --i) {
let handlerInfo = routeInfos[i];
let route = handlerInfo.route;
let routeInfo = routeInfos[i];
let route = routeInfo.route;

// handlerInfo.handler being `undefined` generally means either:
// routeInfo.handler being `undefined` generally means either:
//
// 1. an error occurred during creation of the route in question
// 2. the route is across an async boundary (e.g. within an engine)
Expand All @@ -1373,7 +1373,7 @@ function forEachRouteAbove(
continue;
}

if (callback(route, handlerInfo) !== true) {
if (callback(route, routeInfo) !== true) {
return;
}
}
Expand All @@ -1395,12 +1395,12 @@ let defaultActionHandlers = {
error(routeInfos: PrivateRouteInfo[], error: Error, transition: Transition) {
let router: any = this;

let handlerInfoWithError = routeInfos[routeInfos.length - 1];
let routeInfoWithError = routeInfos[routeInfos.length - 1];

forEachRouteAbove(routeInfos, (route: Route, routeInfo: PrivateRouteInfo) => {
// We don't check the leaf most handlerInfo since that would
// We don't check the leaf most routeInfo since that would
// technically be below where we're at in the route hierarchy.
if (routeInfo !== handlerInfoWithError) {
if (routeInfo !== routeInfoWithError) {
// Check for the existence of an 'error' route.
let errorRouteName = findRouteStateName(route, 'error');
if (errorRouteName) {
Expand Down Expand Up @@ -1428,12 +1428,12 @@ let defaultActionHandlers = {
loading(routeInfos: PrivateRouteInfo[], transition: Transition) {
let router: any = this;

let handlerInfoWithSlowLoading = routeInfos[routeInfos.length - 1];
let routeInfoWithSlowLoading = routeInfos[routeInfos.length - 1];

forEachRouteAbove(routeInfos, (route: Route, handlerInfo: PrivateRouteInfo) => {
// We don't check the leaf most handlerInfo since that would
forEachRouteAbove(routeInfos, (route: Route, routeInfo: PrivateRouteInfo) => {
// We don't check the leaf most routeInfos since that would
// technically be below where we're at in the route hierarchy.
if (handlerInfo !== handlerInfoWithSlowLoading) {
if (routeInfo !== routeInfoWithSlowLoading) {
// Check for the existence of a 'loading' route.
let loadingRouteName = findRouteStateName(route, 'loading');
if (loadingRouteName) {
Expand Down Expand Up @@ -1558,11 +1558,11 @@ export function triggerEvent(
}

let eventWasHandled = false;
let handlerInfo, handler, actionHandler;
let routeInfo, handler, actionHandler;

for (let i = routeInfos.length - 1; i >= 0; i--) {
handlerInfo = routeInfos[i];
handler = handlerInfo.route;
routeInfo = routeInfos[i];
handler = routeInfo.route;
actionHandler = handler && handler.actions && handler.actions[name];
if (actionHandler) {
if (actionHandler.apply(handler, args) === true) {
Expand Down Expand Up @@ -1599,13 +1599,13 @@ function calculatePostTransitionState(
let { routeInfos, params } = state;

for (let i = 0; i < routeInfos.length; ++i) {
let handlerInfo = routeInfos[i];
let routeInfo = routeInfos[i];

// If the handlerInfo is not resolved, we serialize the context into params
if (!handlerInfo.isResolved) {
params[handlerInfo.name] = handlerInfo.serialize(handlerInfo.context);
// If the routeInfo is not resolved, we serialize the context into params
if (!routeInfo.isResolved) {
params[routeInfo.name] = routeInfo.serialize(routeInfo.context);
} else {
params[handlerInfo.name] = handlerInfo.params;
params[routeInfo.name] = routeInfo.params;
}
}
return state;
Expand Down
12 changes: 6 additions & 6 deletions packages/@ember/-internals/routing/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,25 @@ export function stashParamNames(router: EmberRouter, routeInfos: PrivateRouteInf
}

// This helper exists because router.js/route-recognizer.js awkwardly
// keeps separate a handlerInfo's list of parameter names depending
// keeps separate a routeInfo's list of parameter names depending
// on whether a URL transition or named transition is happening.
// Hopefully we can remove this in the future.
let targetRouteName = routeInfos[routeInfos.length - 1].name;
let recogHandlers = router._routerMicrolib.recognizer.handlersFor(targetRouteName);
let dynamicParent: PrivateRouteInfo;

for (let i = 0; i < routeInfos.length; ++i) {
let handlerInfo = routeInfos[i];
let routeInfo = routeInfos[i];
let names = recogHandlers[i].names;

if (names.length) {
dynamicParent = handlerInfo;
dynamicParent = routeInfo;
}

handlerInfo['_names'] = names;
routeInfo['_names'] = names;

let route = handlerInfo.route!;
route._stashNames(handlerInfo, dynamicParent!);
let route = routeInfo.route!;
route._stashNames(routeInfo, dynamicParent!);
}

routeInfos['_namesStashed'] = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ moduleFor(
};
},

_getQPMeta(handlerInfo) {
let handler = this._seenHandlers[handlerInfo.name];
_getQPMeta(routeInfo) {
let handler = this._seenHandlers[routeInfo.name];
if (handler) {
return get(handler, '_qp');
}
Expand Down