fix bug where favicon changes incorrectly
This commit is contained in:
parent
edb621e0f5
commit
95c3349db7
|
@ -1,14 +1,17 @@
|
||||||
// borrowed from https://github.com/HenrikJoreteg/favicon-setter
|
// borrowed from https://github.com/HenrikJoreteg/favicon-setter
|
||||||
export function setFavicon (href) {
|
export function setFavicon (href) {
|
||||||
let faviconId = 'theFavicon'
|
let faviconId = 'theFavicon'
|
||||||
let link = document.createElement('link')
|
|
||||||
let oldLink = document.getElementById(faviconId)
|
let oldLink = document.getElementById(faviconId)
|
||||||
|
|
||||||
|
if (oldLink.getAttribute('href') === href) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let link = document.createElement('link')
|
||||||
link.id = faviconId
|
link.id = faviconId
|
||||||
link.rel = 'shortcut icon'
|
link.rel = 'shortcut icon'
|
||||||
link.type = 'image/png'
|
link.type = 'image/png'
|
||||||
link.href = href
|
link.href = href
|
||||||
if (oldLink) {
|
document.head.removeChild(oldLink)
|
||||||
document.head.removeChild(oldLink)
|
|
||||||
}
|
|
||||||
document.head.appendChild(link)
|
document.head.appendChild(link)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue