Fixes #8722. Remove try/catch used by #3533 to fix the IE Table Colon Blow bug, and instead check for colon in the event name. Thanks to daguej for scoping this out -- a colonoscopy you might say.
This commit is contained in:
parent
c470db6950
commit
98d83ef85f
26
src/event.js
26
src/event.js
|
@ -280,9 +280,7 @@ jQuery.event = {
|
||||||
trigger: function( event, data, elem ) {
|
trigger: function( event, data, elem ) {
|
||||||
// Event object or event type
|
// Event object or event type
|
||||||
var type = event.type || event,
|
var type = event.type || event,
|
||||||
ontype = "on" + type,
|
namespaces = [];
|
||||||
namespaces = [],
|
|
||||||
cur = elem;
|
|
||||||
|
|
||||||
event = typeof event === "object" ?
|
event = typeof event === "object" ?
|
||||||
// jQuery.Event object
|
// jQuery.Event object
|
||||||
|
@ -342,6 +340,10 @@ jQuery.event = {
|
||||||
data = jQuery.makeArray( data );
|
data = jQuery.makeArray( data );
|
||||||
data.unshift( event );
|
data.unshift( event );
|
||||||
|
|
||||||
|
var cur = elem,
|
||||||
|
// IE doesn't like method names with a colon (#3533, #8272)
|
||||||
|
ontype = type.indexOf(":") < 0? "on" + type : "";
|
||||||
|
|
||||||
// Fire event on the current element, then bubble up the DOM tree
|
// Fire event on the current element, then bubble up the DOM tree
|
||||||
do {
|
do {
|
||||||
var handle = jQuery._data( cur, "handle" );
|
var handle = jQuery._data( cur, "handle" );
|
||||||
|
@ -351,13 +353,11 @@ jQuery.event = {
|
||||||
handle.apply( cur, data );
|
handle.apply( cur, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger an inline bound script; IE<9 dies on special-char event name
|
// Trigger an inline bound script
|
||||||
try {
|
if ( ontype &&jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
|
||||||
if ( jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
|
event.result = false;
|
||||||
event.result = false;
|
event.preventDefault();
|
||||||
event.preventDefault();
|
}
|
||||||
}
|
|
||||||
} catch ( ieError1 ) {}
|
|
||||||
|
|
||||||
// Bubble up to document, then to window
|
// Bubble up to document, then to window
|
||||||
cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
|
cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
|
||||||
|
@ -373,9 +373,9 @@ jQuery.event = {
|
||||||
|
|
||||||
// Call a native DOM method on the target with the same name name as the event.
|
// Call a native DOM method on the target with the same name name as the event.
|
||||||
// Can't use an .isFunction)() check here because IE6/7 fails that test.
|
// Can't use an .isFunction)() check here because IE6/7 fails that test.
|
||||||
// Use try/catch so IE<9 won't die on special-char event name or hidden element (#3533).
|
// IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
|
||||||
try {
|
try {
|
||||||
if ( elem[ type ] ) {
|
if ( ontype && elem[ type ] ) {
|
||||||
// Don't re-trigger an onFOO event when we call its FOO() method
|
// Don't re-trigger an onFOO event when we call its FOO() method
|
||||||
old = elem[ ontype ];
|
old = elem[ ontype ];
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ jQuery.event = {
|
||||||
jQuery.event.triggered = type;
|
jQuery.event.triggered = type;
|
||||||
elem[ type ]();
|
elem[ type ]();
|
||||||
}
|
}
|
||||||
} catch ( ieError2 ) {}
|
} catch ( ieError ) {}
|
||||||
|
|
||||||
if ( old ) {
|
if ( old ) {
|
||||||
elem[ ontype ] = old;
|
elem[ ontype ] = old;
|
||||||
|
|
|
@ -2055,6 +2055,19 @@ test("focusin bubbles", function() {
|
||||||
jQuery( "body" ).unbind( "focusin.focusinBubblesTest" );
|
jQuery( "body" ).unbind( "focusin.focusinBubblesTest" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("custom events with colons (#3533, #8272)", function() {
|
||||||
|
expect(1);
|
||||||
|
|
||||||
|
var tab = jQuery("<table><tr><td>trigger</td></tr></table>").appendTo("body");
|
||||||
|
try {
|
||||||
|
tab.trigger("back:forth");
|
||||||
|
ok( true, "colon events don't throw" );
|
||||||
|
} catch ( e ) {
|
||||||
|
ok( false, "colon events die" );
|
||||||
|
};
|
||||||
|
tab.remove();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
// This code must be run before DOM ready!
|
// This code must be run before DOM ready!
|
||||||
|
|
Loading…
Reference in a new issue