Test for standard createEvent before IE-specific click method.

Don't fallback to fake click; let's see which browsers fail, if any.
This commit is contained in:
Dave Methvin 2010-12-27 12:43:48 -05:00
parent c9e8a95709
commit b8931f7448

View file

@ -300,17 +300,14 @@ test("bind/delegate bubbling, isDefaultPrevented", function() {
var $anchor2 = jQuery( "#anchor2" ), var $anchor2 = jQuery( "#anchor2" ),
$main = jQuery( "#main" ), $main = jQuery( "#main" ),
fakeClick = function($jq) { fakeClick = function($jq) {
// Prefer a native click so we don't get jQuery simulated bubbling // Use a native click so we don't get jQuery simulated bubbling
if ( $jq[0].click ) { if ( document.createEvent ) {
$jq[0].click(); // IE
}
else if ( document.createEvent ) {
var e = document.createEvent( 'MouseEvents' ); var e = document.createEvent( 'MouseEvents' );
e.initEvent( "click", true, true ); e.initEvent( "click", true, true );
$jq[0].dispatchEvent(e); $jq[0].dispatchEvent(e);
} }
else { else if ( $jq[0].click ) {
$jq.click(); $jq[0].click(); // IE
} }
}; };
$anchor2.click(function(e) { $anchor2.click(function(e) {