Fix sorting of lists in "Filter lists" pane

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2645#issuecomment-1556090600
This commit is contained in:
Raymond Hill 2023-05-21 09:42:30 -04:00
parent 2a9378b5a8
commit e50d6ee6ed
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 7 additions and 7 deletions

View File

@ -312,7 +312,7 @@ select {
.countryFlag { .countryFlag {
height: var(--font-size); height: var(--font-size);
position: relative; position: relative;
top: calc(var(--font-size) / 6); top: calc(var(--font-size) / 7);
width: calc(var(--font-size) * 1.4); width: calc(var(--font-size) * 1.4);
} }

View File

@ -173,9 +173,10 @@ const renderFilterLists = ( ) => {
const listEntries = dom.clone('#templates .listEntries'); const listEntries = dom.clone('#templates .listEntries');
const treeEntries = Object.entries(listTree); const treeEntries = Object.entries(listTree);
if ( depth !== 0 ) { if ( depth !== 0 ) {
const reEmojis = /[\p{Emoji}]/gu;
treeEntries.sort((a ,b) => { treeEntries.sort((a ,b) => {
const as = a[1].title || a[0]; const as = (a[1].title || a[0]).replace(reEmojis, '');
const bs = b[1].title || b[0]; const bs = (b[1].title || b[0]).replace(reEmojis, '');
return as.localeCompare(bs); return as.localeCompare(bs);
}); });
} }

View File

@ -318,19 +318,18 @@ if ( isBackgroundProcess !== true ) {
const match = reUnicodeFlags.exec(text); const match = reUnicodeFlags.exec(text);
if ( match === null ) { break; } if ( match === null ) { break; }
if ( match.index > i ) { if ( match.index > i ) {
fragment.append(document.createTextNode(text.slice(i, match.index))); fragment.append(text.slice(i, match.index));
} }
const img = document.createElement('img'); const img = document.createElement('img');
const countryCode = unicodeFlagToImageSrc.get(match[0]); const countryCode = unicodeFlagToImageSrc.get(match[0]);
img.src = `/img/flags-of-the-world/${countryCode}.png`; img.src = `/img/flags-of-the-world/${countryCode}.png`;
img.title = countryCode; img.title = countryCode;
img.classList.add('countryFlag'); img.classList.add('countryFlag');
fragment.append(img); fragment.append(img, '\u2009');
fragment.append(document.createTextNode('\u2009'));
i = reUnicodeFlags.lastIndex; i = reUnicodeFlags.lastIndex;
} }
if ( i < text.length ) { if ( i < text.length ) {
fragment.append(document.createTextNode(text.slice(i))); fragment.append(text.slice(i));
} }
return fragment; return fragment;
}; };