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

TypeError : cannot read property "type" of undefined (+ fix) #3394

Closed
2 tasks
Leogiciel opened this issue Mar 27, 2017 · 4 comments
Closed
2 tasks

TypeError : cannot read property "type" of undefined (+ fix) #3394

Leogiciel opened this issue Mar 27, 2017 · 4 comments
Milestone

Comments

@Leogiciel
Copy link

Leogiciel commented Mar 27, 2017

This issue tracker is for Bug Reports and Feature Requests only.
Please direct requests for help to StackOverflow. See http://bit.ly/UIR-SOF for details.

This is a:

  • [X ] Bug Report
  • Feature Request
  • General Query

My version of UI-Router is: 0.4.2

Bug Report

Current Behavior:

angular.js:14328 TypeError: Cannot read property 'type' of undefined at http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular-ui-router.js:3517:44 at Array.reduce (native) at Object.is (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular-ui-router.js:3515:44) at exactMatch (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular-ui-router.js:4632:58) at update (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular-ui-router.js:4621:15) at Scope.$broadcast (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular.js:18298:28) at http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular-ui-router.js:3427:22 at processQueue (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular.js:16648:37) at http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular.js:16692:27 at Scope.$eval (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular.js:17972:28)

Expected Behavior:

No error in the console

Possible fix:

Actual code at line 3517 is:
return acc && !paramDef || paramDef.type.equals($stateParams[key], params[key]);
If "acc" is false and "paramDef" is undefined, due to operators priority "acc && !paramDef" is interpreted first and is false, so "paraDef.type.equals($stateParams[key], params[key]);" is interpreted, and logically throws an exception.

Fixed that this way:
return acc && (!paramDef || paramDef.type.equals($stateParams[key], params[key]));

@christopherthielen christopherthielen added this to the 1.0.0-rc.2 milestone Mar 29, 2017
@kmaraz
Copy link

kmaraz commented Apr 13, 2017

But it could be interpreted like:
return (acc && !paramDef) || paramDef.type.equals($stateParams[key], params[key]);
right?

@christopherthielen christopherthielen modified the milestones: 1.0.1, 1.0.0-rc.2 May 3, 2017
@christopherthielen
Copy link
Contributor

Whoops, closed wrong issue

@Okyne
Copy link

Okyne commented Dec 13, 2017

Any news about this fix ?

@stale
Copy link

stale bot commented Jan 24, 2020

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues
may be reopened.

Thank you for your contributions.

@stale stale bot added the stale label Jan 24, 2020
@stale stale bot closed this as completed Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants