Only add element for user stylesheet if needed and add it to html rather

than body
This commit is contained in:
Kovid Goyal 2019-09-16 09:21:02 +05:30
parent 62810e5111
commit 599d3dbddc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -38,12 +38,13 @@ def apply_colors():
def apply_stylesheet(): def apply_stylesheet():
sid = 'calibre-browser-viewer-user-stylesheet' if opts.user_stylesheet:
style = document.getElementById(sid) sid = 'calibre-browser-viewer-user-stylesheet'
if not style: style = document.getElementById(sid)
style = E.style(type='text/css', id=sid) if not style:
document.body.appendChild(style) style = E.style(type='text/css', id=sid)
style.textContent = opts.user_stylesheet or '' document.documentElement.appendChild(style)
style.textContent = opts.user_stylesheet
def apply_settings(): def apply_settings():