File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
packages/ember-routing/lib/location Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 44*/
55
66var get = Ember . get , set = Ember . set ;
7- var popstateReady = false ;
7+ var popstateFired = false ;
88
99/**
1010 Ember.HistoryLocation implements the location API using the browser's
@@ -18,6 +18,7 @@ Ember.HistoryLocation = Ember.Object.extend({
1818
1919 init : function ( ) {
2020 set ( this , 'location' , get ( this , 'location' ) || window . location ) ;
21+ this . _initialUrl = this . getURL ( ) ;
2122 this . initState ( ) ;
2223 } ,
2324
@@ -70,7 +71,6 @@ Ember.HistoryLocation = Ember.Object.extend({
7071 path = this . formatURL ( path ) ;
7172
7273 if ( this . getState ( ) && this . getState ( ) . path !== path ) {
73- popstateReady = true ;
7474 this . pushState ( path ) ;
7575 }
7676 } ,
@@ -88,7 +88,6 @@ Ember.HistoryLocation = Ember.Object.extend({
8888 path = this . formatURL ( path ) ;
8989
9090 if ( this . getState ( ) && this . getState ( ) . path !== path ) {
91- popstateReady = true ;
9291 this . replaceState ( path ) ;
9392 }
9493 } ,
@@ -142,8 +141,10 @@ Ember.HistoryLocation = Ember.Object.extend({
142141 self = this ;
143142
144143 Ember . $ ( window ) . bind ( 'popstate.ember-location-' + guid , function ( e ) {
145- if ( ! popstateReady ) {
146- return ;
144+ // Ignore initial page load popstate event in Chrome
145+ if ( ! popstateFired ) {
146+ popstateFired = true ;
147+ if ( self . getURL ( ) === self . _initialUrl ) { return ; }
147148 }
148149 callback ( self . getURL ( ) ) ;
149150 } ) ;
You can’t perform that action at this time.
0 commit comments