Permalink
Browse files

Popup: Avoid calling _close() twice

Fixes gh-7917
Closes gh-7919
  • Loading branch information...
gabrielschulhof committed Jan 14, 2015
1 parent 841db13 commit a61d152a21008f3c7edc7f2415710553d625bb95
Showing with 17 additions and 5 deletions.
  1. +2 −1 js/widgets/popup.js
  2. +2 −2 tests/integration/popup/index.html
  3. +13 −2 tests/integration/popup/popup_core.js
View
@@ -816,7 +816,8 @@ $.widget( "mobile.popup", {
currentOptions = this.options,
immediate = false;
if ( ( theEvent && theEvent.isDefaultPrevented() ) || $.mobile.popup.active !== this ) {
if ( ( theEvent && theEvent.isDefaultPrevented() ) || $.mobile.popup.active !== this ||
!this._isOpen ) {
return;
}
@@ -46,7 +46,7 @@
<div data-nstest-role="page" id="start-page">
<div data-nstest-role="content" id="page-content">
<div data-nstest-role="popup" id="test-popup">
<div data-nstest-role="popup" data-nstest-transition="fade" id="test-popup">
<p>This is the test popup</p>
<a href="other.html">other.html</a>
</div>
@@ -98,7 +98,7 @@
</div>
<div id="already-enhanced-screen" class="ui-popup-screen ui-screen-hidden"></div>
<div id="already-enhanced-popup" class="ui-popup-container ui-popup-hidden">
<div id="already-enhanced" data-nstest-enhanced="true" data-nstest-role="popup" class="ui-popup ui-overlay-shadow ui-body-inherit ui-corner-all">
<div id="already-enhanced" data-nstest-enhanced="true" data-nstest-transition="fade" data-nstest-role="popup" class="ui-popup ui-overlay-shadow ui-body-inherit ui-corner-all">
<p>This is a popup already enhanced</p>
</div>
</div>
@@ -5,11 +5,13 @@
var urlObject = $.mobile.path.parseLocation(),
home = urlObject.pathname + urlObject.search,
originalAnimationComplete = $.fn.animationComplete,
animationCompleteCallCount = 0,
opensAndCloses = function( eventNs, popupId, linkSelector, contentSelector ) {
var $popup = $( document.getElementById( popupId ) ),
link = $( linkSelector )[ 0 ];
expect( 13 );
expect( 14 );
$.testHelper.detailedEventCascade([
function() {
@@ -34,7 +36,8 @@
ok( $popup.parent().prev().hasClass( "in" ), popupId + ": Setting an overlay theme while the popup is open causes the theme to be applied and the screen to be faded in" );
ok( $popup.parent().hasClass( "ui-popup-active" ), popupId + ": Open popup has the 'ui-popup-active' class" );
$popup.popup( "close" );
animationCompleteCallCount = 0;
$.mobile.back();
},
{
@@ -43,6 +46,7 @@
},
function( result) {
deepEqual( animationCompleteCallCount, 1, "animationComplete called only once" );
deepEqual( link.getAttribute( "aria-expanded" ), "false", "'aria-expanded' attribute is set to false when the popup is not open" );
ok( !$popup.parent().hasClass( "in" ), "Closed popup container does not have class 'in'" );
ok( $popup.parent().prev().hasClass( "ui-screen-hidden" ), "Closed popup screen is hidden" );
@@ -59,6 +63,13 @@
$.mobile.navigate.history.stack = [];
$.mobile.navigate.history.activeIndex = 0;
$.testHelper.navReset( home );
$.fn.animationComplete = $.extend( function() {
animationCompleteCallCount++;
return originalAnimationComplete.apply( this, arguments );
}, $.fn.animationComplete );
},
teardown: function() {
$.fn.animationComplete = originalAnimationComplete;
}
});

0 comments on commit a61d152

Please sign in to comment.