Просмотр исходного кода

Remove stale dynamic favicon links (#9127)

* Remove stale dynamic favicon links

- remove every previous dynamic favicon link before appending the updated unread-count icon
- prevent stale duplicate favicon links from being preferred by browsers

Fixes #8237.

* Replace dynamic favicon in place

---------

Co-authored-by: Gerard Alvear <gerard.alvear@logiqd.me>
Co-authored-by: Inverle <inverle@proton.me>
Gerard Alvear Porras 3 недель назад
Родитель
Сommit
24039afb10
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      p/scripts/main.js

+ 3 - 3
p/scripts/main.js

@@ -2315,7 +2315,8 @@ function faviconNbUnread(n) {
 		return;
 	}
 	const svgBase = dynamicFaviconBase.innerHTML;
-	const link = document.getElementById('favicon')?.cloneNode(true);
+	const favicon = document.getElementById('favicon');
+	const link = favicon?.cloneNode(true);
 	if (link) {
 		let svgOutput = '';
 		if (n > 0) {
@@ -2351,8 +2352,7 @@ function faviconNbUnread(n) {
 			temp.remove();
 		}
 		link.href = `data:image/svg+xml;base64,${btoa(svgOutput || svgBase)}`;
-		document.querySelector('#favicon').remove();
-		document.head.appendChild(link);
+		favicon.replaceWith(link);
 	}
 }