Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use originalEvent in preference to from

  • Loading branch information...
commit 6faccf8ba527fcef7ba99c94897bad322002cc8f 1 parent 42a8592
@johnbender johnbender authored
View
19 js/navigation/events/navigate.js
@@ -17,13 +17,17 @@ define([ "jquery",
// TODO use the originalEvent property on the event object
// instead of from
popstate: function( event ) {
- var state = event.originalEvent.state;
+ var newEvent = new $.Event( "navigate" ),
+ state = event.originalEvent.state;
+
+ // Make sure the original event is tracked for the end
+ // user to inspect incase they want to do something special
+ newEvent.originalEvent = event;
// NOTE the `|| {}` is there to ensure consistency between
// the popstate navigate event and the hashchange navigate
// event data
- $win.trigger( new $.Event( "navigate" ), {
- from: "popstate",
+ $win.trigger( newEvent, {
state: state || {}
});
},
@@ -31,10 +35,15 @@ define([ "jquery",
// TODO use the originalEvent property on the event object
// instead of from
hashchange: function( event, data ) {
+ var newEvent = new $.Event( "navigate" );
+
+ // Make sure the original event is tracked for the end
+ // user to inspect incase they want to do something special
+ newEvent.originalEvent = event;
+
// Trigger the hashchange with state provided by the user
// that altered the hash
- $win.trigger( new $.Event( "navigate" ), {
- from: "hashchange",
+ $win.trigger( newEvent, {
// Users that want to fully normalize the two events
// will need to do history management down the stack and
// add the state to the event before this binding is fired
View
4 tests/unit/navigation/event/navigate_core.js
@@ -36,7 +36,7 @@ $.testHelper.setPushState();
asyncTest( "navigation events are marked", function() {
$( window ).one( "navigate", function( event, data ) {
- equal( data.from, $.support.pushState ? "popstate" : "hashchange", "tagged as popstate" );
+ equal( event.originalEvent.type, $.support.pushState ? "popstate" : "hashchange", "tagged as popstate" );
start();
});
@@ -65,7 +65,7 @@ $.testHelper.setPushState();
asyncTest( "hashchange navigation provides for data added in a later binding", function() {
$( window ).one( "navigate", function( event, data ) {
- equal( data.from, "hashchange", "event triggered by a hashchange" );
+ equal( event.originalEvent.type, "hashchange", "event triggered by a hashchange" );
equal( data.state.foo, "bar", "state provided properly" );
start();
});
Please sign in to comment.
Something went wrong with that request. Please try again.