From 47c0a5a0931965f579a0e6766fb803b297d28f73 Mon Sep 17 00:00:00 2001 From: AStove Date: Mon, 16 Dec 2019 11:08:06 +0100 Subject: [PATCH] Don't remove whole head when appending a stylesheet for a plugin (#1092) --- js/plugins.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index b05ebe3..2dcabc4 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -463,8 +463,10 @@ plugins.factory('userPlugins', function() { jsonp(url, function(data) { // Add the gist stylesheet only once if (document.querySelectorAll('link[rel=stylesheet][href="' + data.stylesheet + '"]').length < 1) { - var stylesheet = ''; - document.getElementsByTagName('head')[0].innerHTML += stylesheet; + var stylesheet = document.createElement("link"); + stylesheet.href = data.stylesheet; + stylesheet.setAttribute('rel', 'stylesheet'); + document.head.appendChild(stylesheet); } element.innerHTML = '
' + data.div + '
'; });