Replace getVectorMenu function with jQuery equivalent

Bug: T292319
Change-Id: I9c9a179b3bcce9eccdf7037818823568f77f2b35
This commit is contained in:
bwang 2021-10-04 12:54:22 -05:00 committed by Bernard Wang
parent d1b9eb9c04
commit 8758f87c4b
1 changed files with 4 additions and 15 deletions

View File

@ -12,18 +12,6 @@ function closeDropdownsOnClickOutside() {
} );
}
/**
* @param {HTMLElement} item
* @return {HTMLElement|null}
*/
function getVectorMenu( item ) {
if ( item.classList.contains( 'vector-menu' ) ) {
return item;
} else {
var parent = /** @type {HTMLElement} */( item.parentNode );
return parent ? getVectorMenu( parent ) : null;
}
}
/**
* Adds icon placeholder for gadgets to use.
*
@ -36,11 +24,12 @@ function getVectorMenu( item ) {
*/
function addPortletLinkHandler( item, data ) {
var link = item.querySelector( 'a' );
var menu = getVectorMenu( item );
var $menu = $( item ).parents( '.vector-menu' );
var menuElement = $menu.length && $menu.get( 0 ) || null;
// Dropdowns which have not got the noicon class are icon capable.
var isIconCapable = menu && menu.classList.contains(
var isIconCapable = menuElement && menuElement.classList.contains(
'vector-menu-dropdown'
) && !menu.classList.contains(
) && !menuElement.classList.contains(
'vector-menu-dropdown-noicon'
);