Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// references to the scripts with them.
"use strict";
const jsdom = require("jsdom")
const path = require("path")
const readFileSync = require("fs").readFileSync;
let doc = jsdom.jsdom(readFileSync(path.join(__dirname, "..", "index.html")));
let linkTag = doc.getElementById("hab-css");
linkTag.href = `/assets/app-${process.env.CSS_SHA}.css`;
let scriptTag = doc.getElementById("hab-js");
scriptTag.src = `/assets/app-${process.env.JS_SHA}.js`;
console.log(jsdom.serializeDocument(doc));
const pending = [doc];
while (pending.length) {
const next = pending.shift();
callback.call(next);
// DOM methods don't pierce into `template`: queue every template up and pass them through to
// the node callback too.
const sub = next.querySelectorAll('template');
for (let i = 0, t; t = sub[i]; ++i) {
pending.push(t.content);
}
}
return jsdom.serializeDocument(doc);
};
function resolveScriptTagSrc(scriptTag, document) {
const path = scriptTag.src.split('/');
const filename = path[path.length - 1];
const { src } = scriptTag;
if (!isUrl(src)) {
numScriptsResolved += 1;
if (numScriptsResolved === numScriptTags) {
indexHtml.content = serializeDocument(document);
callback();
}
return;
}
request({ method: 'GET', url: src, encoding: null }, (err, response, body) => {
if (err) {
console.log(err);
} else {
zip.append(body, { name: filename });
scriptTag.src = filename;
}
numScriptsResolved += 1;
if (numScriptsResolved === numScriptTags) {
indexHtml.content = serializeDocument(document);
function(callback){
console.log("Updating html5 record for id " + html5.id);
//update html5.
Html5.update({id: html5.id}, {output: serializeDocument(doc)}).exec(function(err, html5s) {
if (err) callback(err);
});
callback();
}
],
jsdom.env(indexHtml.content, (innerErr, window) => {
const indexHtmlDoc = window.document;
const scriptTags = indexHtmlDoc.getElementsByTagName('script');
numScriptTags = scriptTags.length;
for (let i = 0; i < numScriptTags; i += 1) {
resolveScriptTagSrc(scriptTags[i], indexHtmlDoc);
}
if (numScriptTags === 0) {
indexHtml.content = serializeDocument(document);
callback();
}
});
}
.then(function () {
addAllAOIDsToBiblio(spec);
spec.buildAlgs();
fs.writeFileSync(outputFile, jsdom.serializeDocument(spec.doc));
});
}
D3Node.prototype.html = function () {
return jsDom.serializeDocument(this.document)
}
}).then(window => {
const html = jsdom.serializeDocument(window.document)
window.close()
handleEvents(onEnd, url)
return html
})
}
function dump() {
return jsdom.serializeDocument(currentWindow.document);
}
jsdom.env(htmlFile, (innerErr, window) => {
const sketchDoc = window.document;
const base = sketchDoc.createElement('base');
const fullUrl = `https://${req.get('host')}${req.originalUrl}`;
base.href = `${fullUrl}/`;
sketchDoc.head.appendChild(base);
resolvePathsForElementsWithAttribute('src', sketchDoc, files);
resolvePathsForElementsWithAttribute('href', sketchDoc, files);
resolveScripts(sketchDoc, files);
resolveStyles(sketchDoc, files);
res.send(serializeDocument(sketchDoc));
});
});