stylesheet.js: Check if document.documentElement exists

Fixes #4244
This commit is contained in:
Florian Bruhin 2018-11-14 11:43:58 +01:00
parent 8dfca6fafb
commit ed84aa8c7b

View File

@ -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");