This repository was archived by the owner on Oct 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +78
-6
lines changed
Expand file tree Collapse file tree 3 files changed +78
-6
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,15 @@ define( [
2525
2626 // resolved and nulled on window.load()
2727 loadDeferred = $ . Deferred ( ) ,
28+
29+ // function that resolves the above deferred
30+ pageIsFullyLoaded = function ( ) {
31+
32+ // Resolve and null the deferred
33+ loadDeferred . resolve ( ) ;
34+ loadDeferred = null ;
35+ } ,
36+
2837 documentUrl = $ . mobile . path . documentUrl ,
2938
3039 // used to track last vclicked element to make sure its value is added to form data
@@ -442,12 +451,12 @@ define( [
442451
443452 $ ( function ( ) { domreadyDeferred . resolve ( ) ; } ) ;
444453
445- $ . mobile . window . load ( function ( ) {
446-
447- // Resolve and null the deferred
448- loadDeferred . resolve ( ) ;
449- loadDeferred = null ;
450- } ) ;
454+ // Account for the possibility that the load event has already fired
455+ if ( document . readyState === "complete" ) {
456+ pageIsFullyLoaded ( ) ;
457+ } else {
458+ $ . mobile . window . load ( pageIsFullyLoaded ) ;
459+ }
451460
452461 $ . when ( domreadyDeferred , $ . mobile . navreadyDeferred ) . done ( function ( ) { $ . mobile . _registerInternalEvents ( ) ; } ) ;
453462} ) ( jQuery ) ;
Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < title > jQuery Mobile Init Test Suite</ title >
6+
7+ < script src ="../../../external/requirejs/require.js "> </ script >
8+ < script src ="../../../js/requirejs.config.js "> </ script >
9+ < script src ="../../requirejs.config.js "> </ script >
10+ < script src ="../../../js/jquery.tag.inserter.js "> </ script >
11+ < script src ="../../jquery.setNameSpace.js "> </ script >
12+ < script src ="../../jquery.testHelper.js "> </ script >
13+
14+ < link rel ="stylesheet " href ="../../../css/themes/default/jquery.mobile.css " />
15+ < link rel ="stylesheet " href ="../../../external/qunit/qunit.css "/>
16+ < link rel ="stylesheet " href ="../../jqm-tests.css "/>
17+ < script src ="../../../external/qunit/qunit.js "> </ script >
18+
19+ < script >
20+ $ . testHelper . asyncLoad ( [
21+ [ "tests/unit/init/no_autoinit_page_core" ]
22+ ] ) ;
23+ </ script >
24+
25+ < script src ="../../swarminject.js "> </ script >
26+ </ head >
27+ < body >
28+
29+ < div id ="qunit "> </ div >
30+
31+ < div data-nstest-role ="page " id ="foo ">
32+ </ div >
33+
34+ < div data-nstest-role ="page " id ="bar " data-nstest-url ="bak ">
35+ </ div >
36+
37+ </ body >
38+ </ html >
Original file line number Diff line number Diff line change 1+ asyncTest ( "resetActivePageHeight() will be called when page is initialized late" , function ( ) {
2+ var resetActivePageHeightCallCount = 0 ;
3+
4+ $ ( document ) . on ( "mobileinit" , function ( ) {
5+ $ . mobile . autoInitializePage = false ;
6+
7+ $ . mobile . resetActivePageHeight = ( function ( original ) {
8+ return function resetActivePageHeight ( ) {
9+ resetActivePageHeightCallCount ++ ;
10+ return original . apply ( this , arguments ) ;
11+ } ;
12+ } ) ( $ . mobile . resetActivePageHeight ) ;
13+ } ) ;
14+
15+ require ( [ "jquery" , "./init" ] , function ( ) {
16+ setTimeout ( function ( ) {
17+ $ . mobile . initializePage ( ) ;
18+
19+ deepEqual ( resetActivePageHeightCallCount , 1 ,
20+ "$.mobile.resetActivePageHeight() was called from delayed initializePage()" ) ;
21+ start ( ) ;
22+ } , 5000 ) ;
23+ } ) ;
24+
25+ } ) ;
You can’t perform that action at this time.
0 commit comments