Merge pull request #4424 from qutebrowser/stylesheet-fix

stylesheet.js: Check if document.documentElement exists
This commit is contained in:
Jay Kamat 2019-02-14 20:14:15 -08:00 committed by GitHub
commit 17eff15ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -80,6 +80,7 @@ Fixed
correctly gets migrated to `always` instead of `when-searching`. correctly gets migrated to `always` instead of `when-searching`.
- Completion highlighting now works again on Qt 5.11.3 and 5.12.1. - 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. - 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 v1.5.2
------ ------

View File

@ -40,6 +40,11 @@ window._qutebrowser.stylesheet = (function() {
// then move the stylesheet to the end. Partially inspired by Stylus: // 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 // https://github.com/openstyles/stylus/blob/1.1.4.2/content/apply.js#L235-L355
function watch_root() { function watch_root() {
if (!document.documentElement) {
root_observer.observe(document, {"childList": true});
return;
}
if (root_elem !== document.documentElement) { if (root_elem !== document.documentElement) {
root_elem = document.documentElement; root_elem = document.documentElement;
root_observer.disconnect(); root_observer.disconnect();
@ -53,7 +58,8 @@ window._qutebrowser.stylesheet = (function() {
function create_style() { function create_style() {
let ns = xhtml_ns; let ns = xhtml_ns;
if (document.documentElement.namespaceURI === svg_ns) { if (document.documentElement &&
document.documentElement.namespaceURI === svg_ns) {
ns = svg_ns; ns = svg_ns;
} }
style_elem = document.createElementNS(ns, "style"); style_elem = document.createElementNS(ns, "style");