This repository was archived by the owner on Oct 8, 2021. It is now read-only.
Navigation: Do not trigger 'navigate' if popstate is default-prevented#8051
Merged
gabrielschulhof merged 2 commits intomasterfrom Apr 7, 2015
Merged
Navigation: Do not trigger 'navigate' if popstate is default-prevented#8051gabrielschulhof merged 2 commits intomasterfrom
gabrielschulhof merged 2 commits intomasterfrom
Conversation
Contributor
|
👍 |
bbf8e03 to
7069e21
Compare
kakul
pushed a commit
to kakul/jquery-mobile
that referenced
this pull request
Apr 14, 2015
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes gh-8045
The load order of navigation/navigator vs. events/navigate does not matter, because
$.event.special.navigateattaches to hashchange/popstate only duringsetup(), so someone must attach a navigate event handler first. This happens during the instantiation of the pagecontainer. That, in turn, is sufficiently late, since navigation/navigator attaches its popstate handler effectively from the outermost IIFE, because a$.mobile.Navigatorobject is instantiated from the outermost IIFE of navigation/method. In contrast, the pagecontainer is instantiated later, during init'sinitializePage().To test manually, load http://jsbin.com/vohozu/3/ from Safari. It refers to the branch for this PR from view.jquerymobile.com. The page should load with the popup displayed.
To assert that a default-prevented popstate does not cause a navigate event, I had to introduce an early popstate handler that prevents default on the popstate event whenever a flag is set on the window object. This will be unnecessary once #8050 is fixed.