mirror of
https://github.com/wassname/template.git
synced 2026-07-31 12:51:00 +08:00
Fixing window variable not defined
This commit is contained in:
Vendored
+17
-12
@@ -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...
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -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...
|
||||
|
||||
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user