justinfagnani / route

A client + server routing library for Dart
BSD 3-Clause "New" or "Revised" License
114 stars 40 forks source link

Route when listen is called to create consistent behaviour for different browsers #32

Open nikgraf opened 11 years ago

nikgraf commented 11 years ago

A proposal to fix the issue of Browsers behave differently on page load. If you start listening with a router in Chrome this will fire a handler on page load. In Firefox it doesn't.

Browsers tend to handle the popstate event differently on page load. Chrome and Safari always emit a popstate event on page load, but Firefox doesn't. see https://developer.mozilla.org/en-US/docs/DOM/window.onpopstate

To create a consistent behavior I propose to copy the concept of Backbone's routing. Backbone routes by default when you starting the history. see https://github.com/documentcloud/backbone/blob/master/backbone.js#L1417 We also could implement a silent option to prevent routing on app start.