Toolbar: Fail gracefully when adding events to non-existent elements

Avoids a type error when `obj` is not set.

Fixes #44526.

Built from https://develop.svn.wordpress.org/trunk@43517


git-svn-id: http://core.svn.wordpress.org/trunk@43346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Konstantin Obenland 2018-07-19 22:00:25 +00:00
parent d0132b292e
commit 51f09ffc2a
3 changed files with 9 additions and 6 deletions

View File

@ -303,10 +303,13 @@ if ( typeof(jQuery) != 'undefined' ) {
* @return {void} * @return {void}
*/ */
var addEvent = function( obj, type, fn ) { var addEvent = function( obj, type, fn ) {
if ( obj.addEventListener ) if ( typeof obj.addEventListener === 'function' ) {
obj.addEventListener( type, fn, false ); obj.addEventListener( type, fn, false );
else if ( obj.attachEvent ) } else if ( typeof obj.attachEvent === 'function' ) {
obj.attachEvent('on' + type, function() { return fn.call(obj, window.event);}); obj.attachEvent( 'on' + type, function() {
return fn.call( obj, window.event );
} );
}
}, },
aB, hc = new RegExp('\\bhover\\b', 'g'), q = [], aB, hc = new RegExp('\\bhover\\b', 'g'), q = [],

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.0-alpha-43513'; $wp_version = '5.0-alpha-43517';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.