Skip to content

Commit ab2a2a9

Browse files
authored
Tests: Workaround a jQuery 1.8 issue with one dialog test
The test "#8958: dialog can be opened while opening" had special behavior in jQuery 1.8 and the patch from commit 7adb13a broke those assumptions. Adjust the test so that it passes again. Closes gh-2229
1 parent b4df487 commit ab2a2a9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/unit/dialog/methods.js

+18
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ QUnit.test( "#8958: dialog can be opened while opening", function( assert ) {
217217
var ready = assert.async( 3 );
218218
assert.expect( 1 );
219219

220+
var jQuery1Dot8 = jQuery.fn.jquery.indexOf( "1.8" ) === 0;
221+
220222
var element = $( "<div>" ).dialog( {
221223
autoOpen: false,
222224
modal: true,
@@ -246,6 +248,15 @@ QUnit.test( "#8958: dialog can be opened while opening", function( assert ) {
246248
// handle a call to the open() method during the process of the dialog
247249
// being opened.
248250
.on( "blur", function() {
251+
252+
// Support: jQuery 1.8 only
253+
// The test never fully worked in jQuery 1.8 since the input's blur
254+
// handler never fired. It's only been uncovered when `ready()` calls
255+
// have been added to all handlers. Skip this handler in jQuery 1.8.
256+
if ( jQuery1Dot8 ) {
257+
return;
258+
}
259+
249260
element.dialog( "open" );
250261

251262
// Detach the handlers to avoid firing them outside of this
@@ -255,6 +266,13 @@ QUnit.test( "#8958: dialog can be opened while opening", function( assert ) {
255266
ready();
256267
} )
257268
.trigger( "focus" );
269+
270+
// Support: jQuery 1.8 only
271+
// Account for the skipped `ready()` call above. To make sure the count
272+
// is constant, call it here instead.
273+
if ( jQuery1Dot8 ) {
274+
ready();
275+
}
258276
} );
259277

260278
QUnit.test( "#5531: dialog width should be at least minWidth on creation", function( assert ) {

0 commit comments

Comments
 (0)