Add icon classes to portlet links without IDs

Only limit the mw-ui-icon-vector-gadget-ID class to portlet links with
IDs.

Bug: T301012
Change-Id: Ib69957b8d44d9b2a02df9f453de262beb8740799
This commit is contained in:
BrandonXLF 2022-02-04 16:48:08 -05:00 committed by Jdlrobson
parent 11b968cf18
commit 1b0af9022b

View file

@ -63,18 +63,22 @@ function addPortletLinkHandler( item, data ) {
'vector-menu-dropdown-noicon' 'vector-menu-dropdown-noicon'
); );
if ( isIconCapable && data.id && link ) { if ( isIconCapable && link ) {
// If class was previously added this will be a no-op so it is safe to call even // If class was previously added this will be a no-op so it is safe to call even
// if we've previously enhanced it. // if we've previously enhanced it.
link.classList.add( link.classList.add(
'mw-ui-icon', 'mw-ui-icon',
'mw-ui-icon-before', 'mw-ui-icon-before'
);
if ( data.id ) {
// The following class allows gadgets developers to style or hide an icon. // The following class allows gadgets developers to style or hide an icon.
// * mw-ui-icon-vector-gadget-<id> // * mw-ui-icon-vector-gadget-<id>
// The class is considered stable and should not be removed without // The class is considered stable and should not be removed without
// a #user-notice. // a #user-notice.
'mw-ui-icon-vector-gadget-' + data.id // eslint-disable-next-line mediawiki/class-doc
); link.classList.add( 'mw-ui-icon-vector-gadget-' + data.id );
}
} }
} }