Skip to content

Dialog tests in IE8 with jQuery 1.7 #1481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/unit/dialog/dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"ui/button.js",
"ui/effect.js",
"ui/effect-blind.js",
"ui/effect-clip.js",
"ui/effect-explode.js",
"ui/dialog.js"
]
Expand Down
88 changes: 46 additions & 42 deletions tests/unit/dialog/dialog_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,90 +59,94 @@ asyncTest( "focus tabbable", function() {

element = $( markup ).dialog( options );
setTimeout(function() {
testFn();
element.remove();
setTimeout( next );
testFn(function done() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering: Is the done function name necessary? Or just a help for debugging?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for debugging.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

element.remove();
setTimeout( next );
});
});
}

function step1() {
element = $( "<div><input><input></div>" ).dialog( options );
setTimeout(function() {
checkFocus( "<div><input><input></div>", options, function( done ) {
var input = element.find( "input:last" ).focus().blur();
element.dialog( "instance" )._focusTabbable();
setTimeout(function() {
equal( document.activeElement, input[ 0 ],
"1. an element that was focused previously." );
element.remove();
setTimeout( step2 );
done();
});
});
}, step2 );
}

function step2() {
checkFocus( "<div><input><input autofocus></div>", options, function() {
checkFocus( "<div><input><input autofocus></div>", options, function( done ) {
equal( document.activeElement, element.find( "input" )[ 1 ],
"2. first element inside the dialog matching [autofocus]" );
done();
}, step3 );
}

function step3() {
checkFocus( "<div><input><input></div>", options, function() {
checkFocus( "<div><input><input></div>", options, function( done ) {
equal( document.activeElement, element.find( "input" )[ 0 ],
"3. tabbable element inside the content element" );
done();
}, step4 );
}

function step4() {
checkFocus( "<div>text</div>", options, function() {
checkFocus( "<div>text</div>", options, function( done ) {
equal( document.activeElement,
element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ],
"4. tabbable element inside the buttonpane" );
done();
}, step5 );
}

function step5() {
checkFocus( "<div>text</div>", {}, function() {
checkFocus( "<div>text</div>", {}, function( done ) {
equal( document.activeElement,
element.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ],
"5. the close button" );
done();
}, step6 );
}

function step6() {
element = $( "<div>text</div>" ).dialog({
autoOpen: false
});
element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide();
element.dialog( "open" );
setTimeout(function() {
equal( document.activeElement, element.parent()[ 0 ], "6. the dialog itself" );
element.remove();
setTimeout( step7 );
});
checkFocus( "<div>text</div>", { autoOpen: false }, function( done ) {
element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide();
element.dialog( "open" );
setTimeout(function() {
equal( document.activeElement, element.parent()[ 0 ], "6. the dialog itself" );
done();
});
}, step7 );
}

function step7() {
element = $( "<div><input name='0'><input name='1' autofocus></div>" ).dialog({
open: function() {
var inputs = $( this ).find( "input" );
inputs.last().keydown(function( event ) {
event.preventDefault();
inputs.first().focus();
});
}
});
setTimeout(function() {
var inputs = element.find( "input" );
equal( document.activeElement, inputs[ 1 ], "Focus starts on second input" );
inputs.last().simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
setTimeout(function() {
equal( document.activeElement, inputs[ 0 ],
"Honor preventDefault, allowing custom focus management" );
element.remove();
start();
}, 50 );
});
checkFocus(
"<div><input><input autofocus></div>",
{
open: function() {
var inputs = $( this ).find( "input" );
inputs.last().keydown(function( event ) {
event.preventDefault();
inputs.first().focus();
});
}
},
function( done ) {
var inputs = element.find( "input" );
equal( document.activeElement, inputs[ 1 ], "Focus starts on second input" );
inputs.last().simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
setTimeout(function() {
equal( document.activeElement, inputs[ 0 ],
"Honor preventDefault, allowing custom focus management" );
done();
}, 50 );
},
start
);
}

step1();
Expand Down
9 changes: 0 additions & 9 deletions tests/unit/dialog/dialog_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,6 @@ test("height", function() {
element.remove();
});

asyncTest( "hide, #5860 - don't leave effects wrapper behind", function() {
expect( 1 );
$( "#dialog1" ).dialog({ hide: "clip" }).dialog( "close" ).dialog( "destroy" );
setTimeout(function() {
equal( $( ".ui-effects-wrapper" ).length, 0 );
start();
}, 500);
});

test("maxHeight", function() {
expect(3);

Expand Down
2 changes: 1 addition & 1 deletion ui/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ return $.widget( "ui.dialog", {
// Without detaching first, the following becomes really slow
.detach();

this.uiDialog.stop( true, true ).remove();
this.uiDialog.remove();

if ( this.originalTitle ) {
this.element.attr( "title", this.originalTitle );
Expand Down