From c52e7c79b2fd6381ba89fb8c40624e6621284743 Mon Sep 17 00:00:00 2001 From: obenland Date: Mon, 6 Aug 2018 19:32:12 +0000 Subject: [PATCH] Toolbar: Check if `obj` is set before using it. Props pento. See #44526. git-svn-id: https://develop.svn.wordpress.org/trunk@43556 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/lib/admin-bar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/_enqueues/lib/admin-bar.js b/src/js/_enqueues/lib/admin-bar.js index 005bdbe096..6b3b8029a9 100644 --- a/src/js/_enqueues/lib/admin-bar.js +++ b/src/js/_enqueues/lib/admin-bar.js @@ -303,9 +303,9 @@ if ( typeof(jQuery) != 'undefined' ) { * @return {void} */ var addEvent = function( obj, type, fn ) { - if ( typeof obj.addEventListener === 'function' ) { + if ( obj && typeof obj.addEventListener === 'function' ) { obj.addEventListener( type, fn, false ); - } else if ( typeof obj.attachEvent === 'function' ) { + } else if ( obj && typeof obj.attachEvent === 'function' ) { obj.attachEvent( 'on' + type, function() { return fn.call( obj, window.event ); } );