Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 6faccf8

Browse files
committed
use originalEvent in preference to from
1 parent 42a8592 commit 6faccf8

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

js/navigation/events/navigate.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,33 @@ define([ "jquery",
1717
// TODO use the originalEvent property on the event object
1818
// instead of from
1919
popstate: function( event ) {
20-
var state = event.originalEvent.state;
20+
var newEvent = new $.Event( "navigate" ),
21+
state = event.originalEvent.state;
22+
23+
// Make sure the original event is tracked for the end
24+
// user to inspect incase they want to do something special
25+
newEvent.originalEvent = event;
2126

2227
// NOTE the `|| {}` is there to ensure consistency between
2328
// the popstate navigate event and the hashchange navigate
2429
// event data
25-
$win.trigger( new $.Event( "navigate" ), {
26-
from: "popstate",
30+
$win.trigger( newEvent, {
2731
state: state || {}
2832
});
2933
},
3034

3135
// TODO use the originalEvent property on the event object
3236
// instead of from
3337
hashchange: function( event, data ) {
38+
var newEvent = new $.Event( "navigate" );
39+
40+
// Make sure the original event is tracked for the end
41+
// user to inspect incase they want to do something special
42+
newEvent.originalEvent = event;
43+
3444
// Trigger the hashchange with state provided by the user
3545
// that altered the hash
36-
$win.trigger( new $.Event( "navigate" ), {
37-
from: "hashchange",
46+
$win.trigger( newEvent, {
3847
// Users that want to fully normalize the two events
3948
// will need to do history management down the stack and
4049
// add the state to the event before this binding is fired

tests/unit/navigation/event/navigate_core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $.testHelper.setPushState();
3636

3737
asyncTest( "navigation events are marked", function() {
3838
$( window ).one( "navigate", function( event, data ) {
39-
equal( data.from, $.support.pushState ? "popstate" : "hashchange", "tagged as popstate" );
39+
equal( event.originalEvent.type, $.support.pushState ? "popstate" : "hashchange", "tagged as popstate" );
4040
start();
4141
});
4242

@@ -65,7 +65,7 @@ $.testHelper.setPushState();
6565

6666
asyncTest( "hashchange navigation provides for data added in a later binding", function() {
6767
$( window ).one( "navigate", function( event, data ) {
68-
equal( data.from, "hashchange", "event triggered by a hashchange" );
68+
equal( event.originalEvent.type, "hashchange", "event triggered by a hashchange" );
6969
equal( data.state.foo, "bar", "state provided properly" );
7070
start();
7171
});

0 commit comments

Comments
 (0)