Insert icon badge text in icon title only if needed

This is to fix the rendering of the menu entry in
Firefox Fenix, which displays both the icon title
and badge text as a menu entry:

Before the fix:
    uBlock Origin (76)         76

After the fix:
    uBlock Origin              76

The badge text will still be part of the icon title
when the icon badge is disabled by the user or when
the platform does not supprt browserAction.setIcon()
(as is the case on current Firefox for Android).
This commit is contained in:
Raymond Hill 2020-01-23 09:16:09 -05:00
parent c49b58bf54
commit 9637ab56a9
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 8 additions and 1 deletions

View File

@ -824,7 +824,14 @@ vAPI.setIcon = (( ) => {
}
}
if ( browserAction.setTitle !== undefined ) {
// Insert the badge text in the title if:
// - the platform does not support browserAction.setIcon(); OR
// - the rendering of the badge is disabled
if (
browserAction.setTitle !== undefined && (
browserAction.setIcon === undefined || (parts & 0b1000) !== 0
)
) {
browserAction.setTitle({
tabId: tab.id,
title: titleTemplate.replace(