diff --git a/resources/skins.vector.js/dropdownMenus.js b/resources/skins.vector.js/dropdownMenus.js index d38296584..151bfa2fc 100644 --- a/resources/skins.vector.js/dropdownMenus.js +++ b/resources/skins.vector.js/dropdownMenus.js @@ -123,8 +123,12 @@ function addPortletLinkHandler( item, data ) { // assign variables after early return. const link = item.querySelector( 'a' ); - const $menu = $( item ).parents( '.vector-menu' ); - const menuElement = $menu.length && $menu.get( 0 ) || null; + const menuElement = /** @type {HTMLElement} */( + item.closest( '.vector-menu' ) + ); + if ( !menuElement ) { + return; + } if ( data.id ) { iconElement = createIconElement( menuElement, link, data.id ); @@ -132,7 +136,7 @@ function addPortletLinkHandler( item, data ) { // The views menu has limited space so we need to decide whether there is space // to accommodate the new item and if not to redirect to the more dropdown. - if ( $menu.prop( 'id' ) === 'p-views' ) { + if ( menuElement.id === 'p-views' ) { const availableWidth = getAvailableViewMenuWidth(); const moreDropdown = document.querySelector( '#p-cactions ul' ); @@ -143,8 +147,7 @@ function addPortletLinkHandler( item, data ) { } } - // Check link.prepend exists for older browser since this is ES5 code - if ( link && iconElement && link.prepend ) { + if ( link && iconElement ) { link.prepend( iconElement ); } } diff --git a/resources/skins.vector.js/limitedWidthToggle.js b/resources/skins.vector.js/limitedWidthToggle.js index 3267f2bc5..8dd0353d1 100644 --- a/resources/skins.vector.js/limitedWidthToggle.js +++ b/resources/skins.vector.js/limitedWidthToggle.js @@ -24,16 +24,7 @@ function init() { toggle.addEventListener( 'click', function () { features.toggle( LIMITED_WIDTH_FEATURE_NAME ); setDataAttribute( toggle ); - // Fire a simulated window resize event (T328121) - let event; - if ( typeof Event === 'function' ) { - event = new Event( 'resize' ); - } else { - // IE11 - event = window.document.createEvent( 'UIEvents' ); - event.initUIEvent( 'resize', true, false, window, 0 ); - } - window.dispatchEvent( event ); + window.dispatchEvent( new Event( 'resize' ) ); } ); } diff --git a/resources/skins.vector.js/menuTabs.js b/resources/skins.vector.js/menuTabs.js index f57029a04..d5651fee8 100644 --- a/resources/skins.vector.js/menuTabs.js +++ b/resources/skins.vector.js/menuTabs.js @@ -14,11 +14,6 @@ function addNoIconClass( item ) { } function init() { - // Feature detect whether the `.closest` api is supported. If not, return early. - if ( !document.body.closest ) { - return; - } - // Enhance previously added items. Array.prototype.forEach.call( document.querySelectorAll( TABS_SELECTOR + ' ' + LIST_ITEM_JS_SELECTOR ),