How to use the jsdom.serializeDocument function in jsdom

To help you get started, we’ve selected a few jsdom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github habitat-sh / habitat / components / builder-web / bin / add-shas-to-index.js View on Github external
// 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));
github google / santa-tracker-web / gulp_scripts / mutate_html / index.js View on Github external
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);
};
github processing / p5.js-web-editor / server / controllers / project.controller.js View on Github external
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);
github benetech / mmlc-api / api / services / ConversionService.js View on Github external
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();
                        }
                    ],
github processing / p5.js-web-editor / server / controllers / project.controller.js View on Github external
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();
    }
  });
}
github whatwg / loader / ecmarkupify.js View on Github external
.then(function () {
    addAllAOIDsToBiblio(spec);
    spec.buildAlgs();

    fs.writeFileSync(outputFile, jsdom.serializeDocument(spec.doc));
  });
}
github d3-node / d3-node / src / index.js View on Github external
D3Node.prototype.html = function () {
  return jsDom.serializeDocument(this.document)
}
github egoist / taki / lib / jsdom.js View on Github external
}).then(window => {
    const html = jsdom.serializeDocument(window.document)
    window.close()
    handleEvents(onEnd, url)
    return html
  })
}
github vslinko / ripster / specs / createHeadlessBrowser.js View on Github external
function dump() {
    return jsdom.serializeDocument(currentWindow.document);
  }
github processing / p5.js-web-editor / server / controllers / embed.controller.js View on Github external
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));
      });
    });