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

Infinite loop in Routable.unroutePath when initialState is set on a parent Route #1231

Closed
rconnamacher opened this issue Aug 2, 2012 · 2 comments
Labels
Milestone

Comments

@rconnamacher
Copy link

Create a Router tree with the following structure:

  App.Router = Ember.Router.extend({
    location: Ember.Location.create({ implementation: 'hash' }),
    enableLogging: true,

    root: Ember.Route.extend({
      initialState: 'stateOne',

      states: {
        stateOne: Ember.Route.extend({
          route: '/dashboard',
        }),
        stateTwo: Ember.Route.extend({
          route: '/state-two',
        }),
        stateThree: Ember.Route.extend({
          route: '/state-three',
        }),
      }          
    })
  })

When using the back button to return to a previous state (other than the default routeOne state), an infinite loop is triggered in Routable.unroutePath.

This happens because unroutePath searches recursively through a state's parents and since subDir has an initialState set, that state (stateOne) is being entered automatically when subDir is entered. stateOne then recursively returns to its parent, which then bounces back to stateOne again.

@rconnamacher
Copy link
Author

Test case (links directly to ember-latest.js on github): http://jsfiddle.net/TS5TZ/1/
Warning: can cause a crash in both Safari and Firefox on my system. Chrome handles it without crashing.

@wagenet
Copy link
Member

wagenet commented Aug 2, 2012

I just fixed this. Thanks for pointing it out.

@wagenet wagenet closed this as completed Aug 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants