How to use the jsdom.level 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 openlink / rdf-editor / js / rdfxml_parser.js View on Github external
var createXMLDocument = function(string) {
        var parser, xmlDoc;
        if (typeof module != 'undefined') {
            var jsdom = require('jsdom');
            xmlDoc = jsdom.jsdom(string, jsdom.level(2, "core"), {});
        } else if (window.DOMParser) {
            parser = new DOMParser();
            xmlDoc = parser.parseFromString(string, 'text/xml');
        } else if (window.ActiveXObject) {
            xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
            // console.log(el._nsStore);
            // console.log("....");
            xmlDoc.async = 'false';
            xmlDoc.loadXML(string);
        }
        return xmlDoc;
    };
github montagejs / montage / tools / mop / lib / transform.js View on Github external
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
 */

var Q = require("q");
var FS = require("q-fs");
var CSSOM = require("cssom");
var URL = require("url");
var jsdom = require("jsdom").jsdom;
var jshint = require("./jshint").JSHINT;
var minifyJavascript = require("./uglify").uglify;
var minifyHtml = require("html-minifier").minify;
var domToHtml = require("jsdom/lib/jsdom/browser/domtohtml").domToHtml;
var Node = require("jsdom").level(1).Node;
var MontageRequire = require("../montage/require/require");
var File = require("./file").File;

exports.transform = function (config, catalog, options) {
    // analyze reference counts for inlinable resources like images and css
    // compile and analyze individual files
    var contents = config.contents;
    return Q.all(Object.keys(contents).map(function (name) {
        var file = contents[name];
        var extension = FS.extension(name).slice(1);
        if (name === "package.json") {
            return transformPackageDescription(
                file,
                options,
                config
            );
github montagejs / montage / tools / mop / lib / bundle.js View on Github external
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
 */

var FS = require("q-fs");
var Hash = require("./hash").Hash;
var Promise = require("../montage/core/promise").Promise;
var jsdom = require("jsdom").jsdom;
var domToHtml = require("jsdom/lib/jsdom/browser/domtohtml").domToHtml;
var Node = require("jsdom").level(1).Node;
var Montage = require("../montage/montage");
var URL = require("../montage/core/url");
var minifyJavascript = require("./uglify").uglify;
var minifyHtml = require("html-minifier").minify;
var File = require("./file").File;

// called once per package
// @param config package configuration
// @param catalog package configuration catalog by location
// @param options universal options
exports.bundle = function (config, catalog, options) {
    if (!options.optimize)
        return;
    if (config.bundle === false || config.bundle === undefined)
        return;
github racker / rackspace-monitoring-gui / test / config.js View on Github external
var initialize = function () {
  global.document = jsdom.jsdom("<div id="test"></div>", jsdom.level(1, "core"));
  global.window = jsdom.jsdom().createWindow();
};
github qrohlf / trianglify / trianglify.js View on Github external
cellpadding: defaults(options.cellpadding, 0.1*options.cellsize || 15),
        noiseIntensity: defaults(options.noiseIntensity, 0),
        x_gradient: defaults(options.x_gradient, Trianglify.randomColor()),
        format: defaults(options.format, "svg"),
        fillOpacity: defaults(options.fillOpacity, 1),
        strokeOpacity: defaults(options.strokeOpacity, 1)
    };

    this.options.y_gradient = options.y_gradient || this.options.x_gradient.map(function(c){return d3.rgb(c).brighter(0.5);});
}

//nodejs stuff
if (typeof module !== 'undefined' && module.exports) {
    d3 = require("d3");
    jsdom = require("jsdom");
    document = new (jsdom.level(1, "core").Document)();
    XMLSerializer = require("xmldom").XMLSerializer;
    btoa = require('btoa');
    module.exports = Trianglify;
}

Trianglify.randomColor = function() {
    var keys = Object.keys(Trianglify.colorbrewer);
    var palette = Trianglify.colorbrewer[keys[Math.floor(Math.random()*keys.length)]];
    keys = Object.keys(palette);
    var colors = palette[keys[Math.floor(Math.random()*keys.length)]];
    return colors;
};

Trianglify.prototype.generate = function(width, height) {
    return new Trianglify.Pattern(this.options, width, height);
};
github montagejs / mop / montage / node.js View on Github external
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
 */

var FS = require("fs");
var PATH = require("path");

var MontageBoot = require("./montage");

var Require = require("./require/require");
var Promise = require("./core/promise");
var URL = require("./core/url");

var jsdom = require("jsdom").jsdom;
var Node = require("jsdom").level(1).Node;
var domToHtml = require("jsdom/lib/jsdom/browser/domtohtml").domToHtml;

exports.bootstrap = function (callback) {
    var command = process.argv.slice(0, 3);
    var args = process.argv.slice(2);
    var program = args.shift();
    FS.realpath(program, function (error, program) {
        if (error) {
            throw new Error(error);
        }
        findPackage(program, function (error, directory) {
            if (error === "Can't find package") {
                loadFreeModule(program, command, args);
            } else if (error) {
                throw new Error(error);
            } else {
github fgnass / express-jsdom / lib / aspects / sync.js View on Github external
var utils = require('../utils');
var DomSync = require('./support/domsync');
var Events = require('jsdom').level(2, 'events');

exports.depends = ['relay', {js: __dirname + '/support/domsync.js'}];

exports.client = function() {
  var domsync = new DomSync(document, 'cl');

  DomSync.defaultFilter.whitelist = function(el) {
    return el.getAttribute('data-doc') && el.getAttribute('data-model');
  };

  var sync = true;
  var dirty = [];
  var flush;

  var flushOnNextTick = function() {
    setTimeout(flushDirtyNodes, 0);
github znerol / node-delta / lib / delta / xmlToDom.js View on Github external
var dom = require("jsdom").level(3, 'core'),
    xml = require("libxmljs"),
    saxToDom = require("./saxToDom.js");

exports.parseXmlString = function(markup) {
    var doc = new dom.Document();
    var parser = new xml.SaxParser(saxToDom.parserForDocument(doc));
    parser.parseString(markup);

    return doc;
};

exports.parseXmlFile = function(path) {
    var doc = new dom.Document();
    var parser = new xml.SaxParser(saxToDom.parserForDocument(doc));
    parser.parseString(markup);