From 127b783bafa1c2a76754a8d9fc0c28a3658cc178 Mon Sep 17 00:00:00 2001 From: Robin Card Date: Fri, 7 Aug 2020 21:11:29 +0100 Subject: [PATCH] Update index.tsx --- client/posts/change-the-website-favicon/index.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/client/posts/change-the-website-favicon/index.tsx b/client/posts/change-the-website-favicon/index.tsx index e1aebc55..7ccc54d3 100644 --- a/client/posts/change-the-website-favicon/index.tsx +++ b/client/posts/change-the-website-favicon/index.tsx @@ -14,18 +14,14 @@ The following function changes the favicon to \`url\`: const setFavicon = function(url) { // Find the current favicon element const favicon = document.querySelector('link[rel="icon"]'); - if (favicon) { - // Update the new link - favicon.href = url; - } else { + if ( !favicon ) { // Create new \`link\` const link = document.createElement('link'); link.rel = 'icon'; - link.href = url; - // Append to the \`head\` element document.head.appendChild(link); } + link.href = url; }; ~~~