Fixing window variable not defined

This commit is contained in:
Shan Carter
2017-06-06 11:44:44 -07:00
parent 04fa4ebb8c
commit 11b5186394
5 changed files with 36 additions and 32 deletions
+17 -12
View File
@@ -17915,18 +17915,23 @@ function renderOnLoad(dom, data) {
}
// If we are in a browser, render automatically...
if(window && window.document) {
var data = {};
renderImmediately(window.document);
window.document.addEventListener("DOMContentLoaded", function (event) {
renderOnLoad(window.document, data);
// Add a banner if we're not on localhost.
if (window.location.hostname !== "localhost" && window.location.origin !== "file://") {
banner(window.document, data);
}
generateCrossref(data);
// console.log(data);
});
var browser = new Function("try { return this === window; }catch(e){ return false; }");
if (browser) {
try {
var data = {};
renderImmediately(window.document);
window.document.addEventListener("DOMContentLoaded", function (event) {
renderOnLoad(window.document, data);
// Add a banner if we're not on localhost.
if (window.location.hostname !== "localhost" && window.location.origin !== "file://") {
banner(window.document, data);
}
generateCrossref(data);
// console.log(data);
});
} catch (error) {
console.error("Window not defined");
}
}
// If we are in node...
+1 -1
View File
File diff suppressed because one or more lines are too long
+17 -12
View File
@@ -41,18 +41,23 @@ function renderOnLoad(dom, data) {
}
// If we are in a browser, render automatically...
if(window && window.document) {
let data = {};
renderImmediately(window.document);
window.document.addEventListener("DOMContentLoaded", (event) => {
renderOnLoad(window.document, data);
// Add a banner if we're not on localhost.
if (window.location.hostname !== "localhost" && window.location.origin !== "file://") {
banner(window.document, data);
}
generateCrossref(data);
// console.log(data);
});
var browser = new Function("try { return this === window; }catch(e){ return false; }");
if (browser) {
try {
var data = {};
renderImmediately(window.document);
window.document.addEventListener("DOMContentLoaded", function (event) {
renderOnLoad(window.document, data);
// Add a banner if we're not on localhost.
if (window.location.hostname !== "localhost" && window.location.origin !== "file://") {
banner(window.document, data);
}
generateCrossref(data);
// console.log(data);
});
} catch (error) {
console.error("Window not defined");
}
}
// If we are in node...
-3
View File
@@ -34,11 +34,8 @@
"rollup": "^0.36.4",
"rollup-plugin-buble": "^0.14.0",
"rollup-plugin-commonjs": "^7.0.0",
"rollup-plugin-livereload": "^0.3.1",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-serve": "^0.1.0",
"rollup-plugin-string": "^2.0.2",
"rollup-plugin-uglify": "^1.0.1",
"rollup-watch": "^2.5.0"
}
}
+1 -4
View File
@@ -1,12 +1,9 @@
import buble from 'rollup-plugin-buble';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import liveReload from 'rollup-plugin-livereload';
import serve from 'rollup-plugin-serve';
import uglify from 'rollup-plugin-uglify';
import string from 'rollup-plugin-string';
const PORT = 8080;
// const PORT = 8080;
// console.log(`open http://localhost:${PORT}/`);
export default {