mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Provide a way to simulate default browser actions. Fixes #5973.
This commit is contained in:
parent
31f1e99500
commit
0252b78201
@ -333,9 +333,12 @@ jQuery.event = {
|
|||||||
|
|
||||||
} else if ( !event.isDefaultPrevented() ) {
|
} else if ( !event.isDefaultPrevented() ) {
|
||||||
var target = event.target, old,
|
var target = event.target, old,
|
||||||
isClick = jQuery.nodeName(target, "a") && type === "click";
|
isClick = jQuery.nodeName(target, "a") && type === "click",
|
||||||
|
special = jQuery.event.special[ type ] || {};
|
||||||
|
|
||||||
|
if ( (!special._default || special._default.call( elem, event ) === false) &&
|
||||||
|
!isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
|
||||||
|
|
||||||
if ( !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
|
|
||||||
try {
|
try {
|
||||||
if ( target[ type ] ) {
|
if ( target[ type ] ) {
|
||||||
// Make sure that we don't accidentally re-trigger the onFOO events
|
// Make sure that we don't accidentally re-trigger the onFOO events
|
||||||
|
@ -72,7 +72,7 @@ test("bind(), multiple events at once and namespaces", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("bind(), namespace with special add", function() {
|
test("bind(), namespace with special add", function() {
|
||||||
expect(9);
|
expect(18);
|
||||||
|
|
||||||
var div = jQuery("<div/>").bind("test", function(e) {
|
var div = jQuery("<div/>").bind("test", function(e) {
|
||||||
ok( true, "Test event fired." );
|
ok( true, "Test event fired." );
|
||||||
@ -81,6 +81,11 @@ test("bind(), namespace with special add", function() {
|
|||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
jQuery.event.special.test = {
|
jQuery.event.special.test = {
|
||||||
|
_default: function(e) {
|
||||||
|
equals( this, document, "Make sure we're at the top of the chain." );
|
||||||
|
equals( e.type, "test", "And that we're still dealing with a test event." );
|
||||||
|
equals( e.target, div[0], "And that the target is correct." );
|
||||||
|
},
|
||||||
setup: function(){},
|
setup: function(){},
|
||||||
teardown: function(){},
|
teardown: function(){},
|
||||||
add: function( handler, data, namespaces ) {
|
add: function( handler, data, namespaces ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user