Permalink
Browse files

Prevents Sizzle error in `initializePage` due to unescaped characters…

…. Can be reproduced by triggering a popup or dialog, then immediately reloading the page: the result is a loading spinner and no page.
  • Loading branch information...
1 parent 1f7ea08 commit bec2ec975970307131d41389e7b5dfbb09b08c01 @Wilto Wilto committed Aug 31, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 js/jquery.mobile.init.js
View
@@ -44,7 +44,10 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
// find and enhance the pages in the dom and transition to the first page.
initializePage: function() {
// find present pages
- var $pages = $( ":jqmData(role='page'), :jqmData(role='dialog')" );
+ var $pages = $( ":jqmData(role='page'), :jqmData(role='dialog')" ),
+ escapeHash = function( hash ) {
+ return hash.replace(/([\\&=])/g, "\\$1");
+ };
// if no pages are found, create one with body's inner html
if ( !$pages.length ) {
@@ -81,9 +84,10 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
// the hash is not valid (contains more than one # or does not start with #)
// or there is no page with that hash, change to the first page in the DOM
// Remember, however, that the hash can also be a path!
+
if ( ! ( $.mobile.hashListeningEnabled &&
$.mobile.path.isHashValid( location.hash ) &&
- ( $( location.hash + ':jqmData(role="page")' ).length ||
+ ( $( escapeHash( location.hash ) + ':jqmData(role="page")' ).length ||
$.mobile.path.isPath( location.hash ) ) ) ) {
// Store the initial destination

1 comment on commit bec2ec9

Contributor

Wilto commented on bec2ec9 Aug 31, 2012

Yep, just confirmed this with @timmywil: http://jsfiddle.net/kyNp9/

Please sign in to comment.