Skip to content

Commit

Permalink
fix: safeguard document usage
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Jan 9, 2017
1 parent 57cce5b commit 63094d3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/render.js
Expand Up @@ -40,20 +40,19 @@ function injectStylesheet(document, stylesheetContent) {

export default function render(loader, options = {}) {
options = assign({
document,
prefix: '',
color: '#333',
background: '#fff',
fullSizeBody: false,
loaderContainerId: 'loader-container',
}, options)

const doc = options.document || (typeof document === 'undefined' && document)
const {prefix, loaderContainerId} = options
const loaderResults = loader(options)
const loaderContainer = options.document.getElementById(loaderContainerId)
const loaderContainer = doc.getElementById(loaderContainerId)

const css = baseCss(options) + '\n' + loaderResults.css
injectStylesheet(options.document, css)
injectStylesheet(doc, baseCss(options) + '\n' + loaderResults.css)
loaderContainer.innerHTML = `
<div class="${prefix}loader-element">
${loaderResults.html || ''}
Expand Down

0 comments on commit 63094d3

Please sign in to comment.