From ed84aa8c7b705bf2d3ac715748c644f1642ce585 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 14 Nov 2018 11:43:58 +0100 Subject: [PATCH] stylesheet.js: Check if document.documentElement exists Fixes #4244 --- qutebrowser/javascript/stylesheet.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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");