diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index d5d76b181..7e6b21e4e 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -80,6 +80,7 @@ Fixed correctly gets migrated to `always` instead of `when-searching`. - Completion highlighting now works again on Qt 5.11.3 and 5.12.1. - The outdated header `X-Do-Not-Track` is no longer sent. +- A javascript error on page load when using Qt 5.12 was fixed. v1.5.2 ------ diff --git a/qutebrowser/javascript/stylesheet.js b/qutebrowser/javascript/stylesheet.js index b1cdeb26e..ce1cc167d 100644 --- a/qutebrowser/javascript/stylesheet.js +++ b/qutebrowser/javascript/stylesheet.js @@ -40,6 +40,11 @@ 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) { + root_observer.observe(document, {"childList": true}); + return; + } + if (root_elem !== document.documentElement) { root_elem = document.documentElement; root_observer.disconnect(); @@ -53,7 +58,8 @@ 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");