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

handle empty route object in routeFinishedSetup #70

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 8 additions & 3 deletions addon/core/transition-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,17 @@ prototype.activateRoute = function activateRoute(route) {
prototype.routeFinishedSetup = function routeFinishedSetup(route) {
let endTime = t();
let [r] = this.routes.filter((r) => r.name === route.routeName);
r.endTime = endTime;
r.elapsedTime = r.endTime - r.startTime;

if (r) {
r.endTime = endTime;
r.elapsedTime = r.endTime - r.startTime;
}
};

prototype._viewAdded = function _viewAdded(view, index) {
this._lastActivatedRoute.views.push(index);
if (this._lastActivatedRoute && this._lastActivatedRoute.views) {
this._lastActivatedRoute.views.push(index);
}
};

export default TransitionData;
21 changes: 13 additions & 8 deletions addon/services/ember-perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {
defer
},
run: { scheduleOnce, schedule },
getWithDefault, get, set, on
getWithDefault, get, set, on, isEmpty
} = Ember;
const Base = Ember.Service || Ember.Object;
const {
Expand Down Expand Up @@ -63,26 +63,31 @@ export default Base.extend(Evented, {
}
transitionInfo.promise._emberPerfTransitionId = transitionCounter++;
let transitionRoute = transitionInfo.promise.targetName || get(transitionInfo.promise, 'intent.name');
let transitionCtxt = get(transitionInfo.promise, 'intent.contexts') ? (get(transitionInfo.promise, 'intent.contexts') || [])[0] : null;
let transitionCtxts = get(transitionInfo.promise, 'intent.contexts');
let transitionUrl = get(transitionInfo.promise, 'intent.url');
assert('Must have at least a route name', transitionRoute);

if (Ember.isEmpty(transitionRoute)) {
return;
}
if (!transitionUrl) {
if (transitionCtxt) {
transitionUrl = transitionInfo.promise.router.generate(transitionRoute, transitionCtxt);
} else {
if (isEmpty(transitionCtxts)) {
transitionUrl = transitionInfo.promise.router.generate(transitionRoute);
} else {
transitionUrl = transitionInfo.promise.router.generate(transitionRoute, transitionCtxts);
}
}
this.renderData = this.transitionData = new TransitionData({
destURL: transitionUrl,
destRoute: transitionRoute
});
transitionInfo.promise.then(() => {
this.transitionData.finish();
}).catch(() => {
}).finally(() => {
let event = this.transitionData;

scheduleOnce('afterRender', () => {
this.trigger('transitionComplete', event);
this.transitionData.finish();
});
});
},
Expand Down Expand Up @@ -179,4 +184,4 @@ export default Base.extend(Evented, {
console.groupEnd();
}
})
});
});