diff --git a/qutebrowser/javascript/stylesheet.js b/qutebrowser/javascript/stylesheet.js index b1cdeb26e..3dfefe700 100644 --- a/qutebrowser/javascript/stylesheet.js +++ b/qutebrowser/javascript/stylesheet.js @@ -40,6 +40,10 @@ window._qutebrowser.stylesheet = (function() { // then move the stylesheet to the end. Partially inspired by Stylus: // https://github.com/openstyles/stylus/blob/1.1.4.2/content/apply.js#L235-L355 function watch_root() { + if (!document.documentElement) { + return; + } + if (root_elem !== document.documentElement) { root_elem = document.documentElement; root_observer.disconnect(); @@ -53,7 +57,7 @@ window._qutebrowser.stylesheet = (function() { function create_style() { let ns = xhtml_ns; - if (document.documentElement.namespaceURI === svg_ns) { + if (document.documentElement && document.documentElement.namespaceURI === svg_ns) { ns = svg_ns; } style_elem = document.createElementNS(ns, "style");