From be6161d02eedde3c7162aac09428a5b3e1d718a8 Mon Sep 17 00:00:00 2001 From: sinyo-matu Date: Sat, 6 May 2023 18:12:54 +0900 Subject: [PATCH] update changeFavicon to only change the href attribute --- d2cli/static/watch.js | 14 ++------------ d2cli/watch.go | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/d2cli/static/watch.js b/d2cli/static/watch.js index c6efceb50..e3a62abac 100644 --- a/d2cli/static/watch.js +++ b/d2cli/static/watch.js @@ -76,16 +76,6 @@ function init(reconnectDelay) { } const changeFavicon = function (iconURL) { - const head = document.getElementsByTagName("head")[0]; - const newLink = document.createElement("link"); - newLink.rel = "icon"; - newLink.href = iconURL; - removeExistingFavicons(); - head.appendChild(newLink); -}; -const removeExistingFavicons = function () { - const links = document.getElementsByTagName("link"); - Array.from(links) - .filter((link) => /\bicon\b/i.test(link.getAttribute("rel"))) - .forEach((link) => link.remove()); + const faviconLink = document.getElementById("favicon-link"); + faviconLink.href = iconURL; }; diff --git a/d2cli/watch.go b/d2cli/watch.go index b352a7b36..0fb3046b7 100644 --- a/d2cli/watch.go +++ b/d2cli/watch.go @@ -429,7 +429,7 @@ func (w *watcher) handleRoot(hw http.ResponseWriter, r *http.Request) { %s - +