From a783bb97d5c31d880782d67d58838e34caed6480 Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Fri, 19 Oct 2018 16:39:18 -0400 Subject: [PATCH] Rename last handlerInfo references to routeInfo --- .../routing/lib/services/routing.ts | 4 +- .../-internals/routing/lib/system/router.ts | 54 +++++++++---------- .../@ember/-internals/routing/lib/utils.ts | 12 ++--- .../query_param_async_get_handler_test.js | 4 +- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/packages/@ember/-internals/routing/lib/services/routing.ts b/packages/@ember/-internals/routing/lib/services/routing.ts index 1674aad8520..1d75841b82b 100644 --- a/packages/@ember/-internals/routing/lib/services/routing.ts +++ b/packages/@ember/-internals/routing/lib/services/routing.ts @@ -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; } } diff --git a/packages/@ember/-internals/routing/lib/system/router.ts b/packages/@ember/-internals/routing/lib/system/router.ts index e8abf73f282..79aabcc85c2 100644 --- a/packages/@ember/-internals/routing/lib/system/router.ts +++ b/packages/@ember/-internals/routing/lib/system/router.ts @@ -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'); } @@ -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; @@ -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) { @@ -1350,19 +1350,19 @@ class EmberRouter extends EmberObject { @private @param {Route} originRoute - @param {Array} routeInfos + @param {Array} 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) @@ -1373,7 +1373,7 @@ function forEachRouteAbove( continue; } - if (callback(route, handlerInfo) !== true) { + if (callback(route, routeInfo) !== true) { return; } } @@ -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) { @@ -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) { @@ -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) { @@ -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; diff --git a/packages/@ember/-internals/routing/lib/utils.ts b/packages/@ember/-internals/routing/lib/utils.ts index 7326c71fffc..6b71c614b19 100644 --- a/packages/@ember/-internals/routing/lib/utils.ts +++ b/packages/@ember/-internals/routing/lib/utils.ts @@ -37,7 +37,7 @@ 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; @@ -45,17 +45,17 @@ export function stashParamNames(router: EmberRouter, routeInfos: PrivateRouteInf 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; diff --git a/packages/ember/tests/routing/query_params_test/query_param_async_get_handler_test.js b/packages/ember/tests/routing/query_params_test/query_param_async_get_handler_test.js index dd9362a0a15..94658703968 100644 --- a/packages/ember/tests/routing/query_params_test/query_param_async_get_handler_test.js +++ b/packages/ember/tests/routing/query_params_test/query_param_async_get_handler_test.js @@ -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'); }