Skip to content

Commit

Permalink
Fix sorting of lists in "Filter lists" pane
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed May 21, 2023
1 parent 2a9378b commit e50d6ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ select {
.countryFlag {
height: var(--font-size);
position: relative;
top: calc(var(--font-size) / 6);
top: calc(var(--font-size) / 7);
width: calc(var(--font-size) * 1.4);
}

Expand Down
5 changes: 3 additions & 2 deletions src/js/3p-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ const renderFilterLists = ( ) => {
const listEntries = dom.clone('#templates .listEntries');
const treeEntries = Object.entries(listTree);
if ( depth !== 0 ) {
const reEmojis = /[\p{Emoji}]/gu;
treeEntries.sort((a ,b) => {
const as = a[1].title || a[0];
const bs = b[1].title || b[0];
const as = (a[1].title || a[0]).replace(reEmojis, '');
const bs = (b[1].title || b[0]).replace(reEmojis, '');
return as.localeCompare(bs);
});
}
Expand Down
7 changes: 3 additions & 4 deletions src/js/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,18 @@ if ( isBackgroundProcess !== true ) {
const match = reUnicodeFlags.exec(text);
if ( match === null ) { break; }
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 countryCode = unicodeFlagToImageSrc.get(match[0]);
img.src = `/img/flags-of-the-world/${countryCode}.png`;
img.title = countryCode;
img.classList.add('countryFlag');
fragment.append(img);
fragment.append(document.createTextNode('\u2009'));
fragment.append(img, '\u2009');
i = reUnicodeFlags.lastIndex;
}
if ( i < text.length ) {
fragment.append(document.createTextNode(text.slice(i)));
fragment.append(text.slice(i));
}
return fragment;
};
Expand Down

0 comments on commit e50d6ee

Please sign in to comment.