fix bug where favicon changes incorrectly

This commit is contained in:
Nolan Lawson 2018-04-11 20:30:38 -07:00
parent edb621e0f5
commit 95c3349db7
1 changed files with 7 additions and 4 deletions

View File

@ -1,14 +1,17 @@
// borrowed from https://github.com/HenrikJoreteg/favicon-setter
export function setFavicon (href) {
let faviconId = 'theFavicon'
let link = document.createElement('link')
let oldLink = document.getElementById(faviconId)
if (oldLink.getAttribute('href') === href) {
return
}
let link = document.createElement('link')
link.id = faviconId
link.rel = 'shortcut icon'
link.type = 'image/png'
link.href = href
if (oldLink) {
document.head.removeChild(oldLink)
}
document.head.appendChild(link)
}