From a030daec51d31259558a79a9666d9457d1db114c Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Fri, 24 Oct 2014 12:31:18 +0300 Subject: [PATCH] Panel: Invalidate _openedPage upon pageshow before recomputing wrapper Fixes gh-7711 --- js/widgets/panel.js | 5 +- .../external-panel-wrapper-update-tests.html | 48 +++++++++++++++++++ .../external_panel_wrapper_update_core.js | 46 ++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 tests/integration/panel/external-panel-wrapper-update-tests.html create mode 100644 tests/integration/panel/external_panel_wrapper_update_core.js diff --git a/js/widgets/panel.js b/js/widgets/panel.js index 52160403991..07af153468e 100644 --- a/js/widgets/panel.js +++ b/js/widgets/panel.js @@ -269,7 +269,10 @@ $.widget( "mobile.panel", { }); if ( !this._parentPage && this.options.display !== "overlay" ) { this._on( this.document, { - "pageshow": "_getWrapper" + "pageshow": function() { + this._openedPage = null; + this._getWrapper(); + } }); } // Clean up open panels after page hide diff --git a/tests/integration/panel/external-panel-wrapper-update-tests.html b/tests/integration/panel/external-panel-wrapper-update-tests.html new file mode 100644 index 00000000000..c9fd5259952 --- /dev/null +++ b/tests/integration/panel/external-panel-wrapper-update-tests.html @@ -0,0 +1,48 @@ + + + + + + jQuery Mobile Panel Test Suite + + + + + + + + + + + + + + + + +
+ +
+

The panel

+ Go to other page +
+ +
+
+

Start page

+
+
+ +
+
+

Other page

+
+
+ diff --git a/tests/integration/panel/external_panel_wrapper_update_core.js b/tests/integration/panel/external_panel_wrapper_update_core.js new file mode 100644 index 00000000000..7e6486b2a88 --- /dev/null +++ b/tests/integration/panel/external_panel_wrapper_update_core.js @@ -0,0 +1,46 @@ +var panel = $( "#wrapper-test-panel" ).panel(); + +asyncTest( "External panel updates wrapper correctly", function() { + var otherPageChildren, + otherPage = $( "#other-page" ), + otherPageLink = $( "#go-to-other-page" ); + + expect( 5 ); + + $.testHelper.detailedEventCascade([ + function() { + panel.panel( "open" ); + }, + { + panelopen: { src: panel, event: "panelopen.externalPanelUpdatesWrapperCorrectly1" } + }, + function( result ) { + deepEqual( result.panelopen.timedOut, false, "Panel did open" ); + otherPageLink.click(); + }, + { + panelclose: { src: panel, event: "panelclose.externalPanelUpdatesWrapperCorrectly2" }, + pagecontainerchange: { + src: $( window ), + event: "pagecontainerchange.externalPanelUpdatesWrapperCorrectly2" + } + }, + function( result ) { + otherPageChildren = otherPage.children(); + deepEqual( result.panelclose.timedOut, false, "Panel did close upon link click" ); + deepEqual( result.pagecontainerchange.timedOut, false, + "pagecontainerchange event received" ); + deepEqual( otherPageChildren.length, 1, "Other page has exactly one child" ); + deepEqual( otherPageChildren.hasClass( "ui-panel-wrapper" ), true, + "Other page child has class 'ui-panel-wrapper'" ); + $.mobile.back(); + }, + { + pagecontainerchange: { + src: $( window ), + event: "pagecontainerchange.externalPanelUpdatesWrapperCorrectly2" + } + }, + start + ]); +});