Skip to content
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
8045-handle-initial-popstate
Apr 7, 2015
Merged

Navigation: Do not trigger 'navigate' if popstate is default-prevented#8051
gabrielschulhof merged 2 commits intomasterfrom
8045-handle-initial-popstate

Conversation

@gabrielschulhof
Copy link

Fixes gh-8045

The load order of navigation/navigator vs. events/navigate does not matter, because $.event.special.navigate attaches to hashchange/popstate only during setup(), 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.Navigator object is instantiated from the outermost IIFE of navigation/method. In contrast, the pagecontainer is instantiated later, during init's initializePage().

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.

@arschmitz
Copy link
Contributor

👍

@gabrielschulhof gabrielschulhof force-pushed the 8045-handle-initial-popstate branch from bbf8e03 to 7069e21 Compare April 7, 2015 10:03
@gabrielschulhof gabrielschulhof merged commit 7069e21 into master Apr 7, 2015
@gabrielschulhof gabrielschulhof deleted the 8045-handle-initial-popstate branch April 7, 2015 12:51
kakul pushed a commit to kakul/jquery-mobile that referenced this pull request Apr 14, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

popup window closes automatically when initiated via javascript

4 participants