Skip to content

Commit 818c2f2

Browse files
author
scottjehl
committed
Add a last-resort fallback to ensure content is accessible if something goes wrong during enhancements, such as a runtime error. Fixes jquery-archive#3648
1 parent 494c5ce commit 818c2f2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

js/jquery.mobile.init.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
2626
$.mobile.ajaxEnabled = false;
2727
}
2828

29-
// add mobile, initial load "rendering" classes to docEl
29+
// Add mobile, initial load "rendering" classes to docEl
3030
$html.addClass( "ui-mobile ui-mobile-rendering" );
31+
32+
// This is a fallback. If anything goes wrong (JS errors, etc), or events don't fire,
33+
// this ensures the rendering class is removed after 5 seconds, so content is visible and accessible
34+
setTimeout( hideRenderingClass, 5000 );
3135

3236
// loading div which appears during Ajax requests
3337
// will not appear if $.mobile.loadingMessage is false
@@ -55,6 +59,11 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
5559
}
5660
}
5761

62+
//remove initial build class (only present on first pageshow)
63+
function hideRenderingClass(){
64+
$html.removeClass( "ui-mobile-rendering" );
65+
}
66+
5867

5968
$.extend($.mobile, {
6069
// turn on/off page loading message.
@@ -124,7 +133,7 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
124133
$.mobile.showPageLoadingMsg();
125134

126135
//remove initial build class (only present on first pageshow)
127-
$html.removeClass( "ui-mobile-rendering" );
136+
hideRenderingClass();
128137

129138
// if hashchange listening is disabled or there's no hash deeplink, change to the first page in the DOM
130139
if ( !$.mobile.hashListeningEnabled || !$.mobile.path.stripHash( location.hash ) ) {

0 commit comments

Comments
 (0)