Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Route inherited param fix #9731

Closed
wants to merge 1 commit into from

Conversation

cmichal
Copy link
Contributor

@cmichal cmichal commented Oct 21, 2014

ngEurope sprint with Vojta & Jeff

@caitp
Copy link
Contributor

caitp commented Oct 21, 2014

LGTM for the first commit

@cmichal
Copy link
Contributor Author

cmichal commented Oct 21, 2014

This contains also code form my previous pr, I'll fix that later on.

@cmichal cmichal force-pushed the routeInheritedParam-fix branch from fc83923 to 254ecc7 Compare October 21, 2014 18:08
@cmichal
Copy link
Contributor Author

cmichal commented Oct 21, 2014

Ok, ready.

@@ -141,10 +141,13 @@ function $RouteProvider(){
* Adds a new route definition to the `$route` service.
*/
this.when = function(path, route) {
var routeCopy = angular.copy(route);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's weird that we're doing the copy() and extend() ... the reason for the copy() is just for the Object.create(Object.getPrototypeOf(route)) --- but it takes some digging to figure out why it works.

How about this:

route = Object.create(Object.getPrototypeOf(route));
if (!'reloadOnSearch' in route) route.reloadOnSearch = true;
routes[path] = angular.extend(routeCopy, path && pathRegExp(path, route));

That way it's clearer why it actually works

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then again, that's wrong too... so I guess copy is okay, but we should explain clearly why it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain in the comment to that code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, add a comment

@caitp caitp added this to the 1.3.x milestone Oct 22, 2014
@caitp caitp self-assigned this Oct 22, 2014
@cmichal cmichal force-pushed the routeInheritedParam-fix branch from 254ecc7 to e0a36c1 Compare October 22, 2014 19:50
@@ -141,10 +141,13 @@ function $RouteProvider(){
* Adds a new route definition to the `$route` service.
*/
this.when = function(path, route) {
var routeCopy = angular.copy(route);
if (angular.isUndefined(routeCopy.reloadOnSearch)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!('reloadOnSearch' in routeCopy))

copy route params with angular.copy before using angular.extend which looks only for enumerable own properties

Closes angular#8181
@cmichal cmichal force-pushed the routeInheritedParam-fix branch from e0a36c1 to 6bdef8e Compare October 22, 2014 20:17
@cmichal
Copy link
Contributor Author

cmichal commented Oct 23, 2014

how can I resubmit build? current one faild because of some issues with browsers in lab...

@caitp
Copy link
Contributor

caitp commented Oct 23, 2014

restarted it for you.

@caitp
Copy link
Contributor

caitp commented Oct 23, 2014

welp, it crashed again in the same way.

@cmichal
Copy link
Contributor Author

cmichal commented Oct 24, 2014

You mean because of lab issues or rather my code issue?

@caitp
Copy link
Contributor

caitp commented Nov 1, 2014

@pkozlowski-opensource do you have any comments on this before I land it? I think we want toget it in shortly


it("should use route params inherited from prototype chain", function() {
var BaseRoute = function BaseRoute() {
BaseRoute.prototype.templateUrl = 'foo.html';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this out of the constructor...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care a whole lot about this in a test, but I suppose we should take this out of the constructor in case anyone ever wants to copy/paste from it

@caitp
Copy link
Contributor

caitp commented Nov 1, 2014

I think i'm just going to make that slight adjustment and land this, we can fix it up later. this doesn't look like it should produce any regressions

@caitp caitp closed this in b477058 Nov 1, 2014
@caitp
Copy link
Contributor

caitp commented Nov 1, 2014

murg'd!

@caitp
Copy link
Contributor

caitp commented Nov 1, 2014

(I'm not sure why we have jshint rules that don't let you call new Class without parentheses -.-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants