Toolbar: Fail gracefully when adding events to non-existent elements
Avoids a type error when `obj` is not set. Fixes #44526. git-svn-id: https://develop.svn.wordpress.org/trunk@43517 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e7d9ee5051
commit
9d4b0ec88f
@ -303,10 +303,13 @@ if ( typeof(jQuery) != 'undefined' ) {
|
||||
* @return {void}
|
||||
*/
|
||||
var addEvent = function( obj, type, fn ) {
|
||||
if ( obj.addEventListener )
|
||||
obj.addEventListener(type, fn, false);
|
||||
else if ( obj.attachEvent )
|
||||
obj.attachEvent('on' + type, function() { return fn.call(obj, window.event);});
|
||||
if ( typeof obj.addEventListener === 'function' ) {
|
||||
obj.addEventListener( type, fn, false );
|
||||
} else if ( typeof obj.attachEvent === 'function' ) {
|
||||
obj.attachEvent( 'on' + type, function() {
|
||||
return fn.call( obj, window.event );
|
||||
} );
|
||||
}
|
||||
},
|
||||
|
||||
aB, hc = new RegExp('\\bhover\\b', 'g'), q = [],
|
||||
|
Loading…
Reference in New Issue
Block a user