fix server render (#443)

This commit is contained in:
Yoshua Wuyts
2017-03-25 10:45:44 +01:00
committed by GitHub
parent 1904f37663
commit 4f8bd24169
3 changed files with 17 additions and 2 deletions
+16
View File
@@ -0,0 +1,16 @@
var assert = require('assert')
module.exports = documentReady
function documentReady (callback) {
assert.notEqual(typeof document, 'undefined', 'document-ready only runs in the browser')
var state = document.readyState
if (state === 'complete' || state === 'interactive') {
return setTimeout(callback, 0)
}
document.addEventListener('DOMContentLoaded', function onLoad () {
callback()
})
}