How to use the domino.createWindow function in domino

To help you get started, we’ve selected a few domino 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 chinakids / node-wiki / tools / markDown.js View on Github external
var markdown = require('marked');
var mermaid = require('mermaid');
var katex = require('katex');
var domino = require('domino');
var Zepto = require('zepto-node');

var window = domino.createWindow();

var $ = Zepto(window);

//初始化 marked 参数
var renderer = new markdown.Renderer();
renderer.listitem = function(text) {
  //console.log(text);
  if (!/^\[[ x]\]\s/.test(text)) {
    return markdown.Renderer.prototype.listitem(text);
  }
  // 任务列表
  var checkbox = $('<input disabled="" type="checkbox">');
  if (/^\[x\]\s/.test(text)) { // 完成的任务列表
    checkbox.attr('checked', true);
  }
  return $(markdown.Renderer.prototype.listitem(text.substring(3))).addClass(
github bazelbuild / rules_nodejs / examples / kotlin / spec.js View on Github external
it('works', () =&gt; {
    const html = '<title>fakeTitle</title>';
    // Domino gives us enough of the DOM API that we can run our JavaScript in node rather than the
    // browser. That makes this test a lot faster
    global.document = domino.createWindow(html, '/').document;
    // Make all Domino types available as types in the global env.
    Object.assign(global, domino.impl);

    // clang-format off
    // (it doesn't understand dynamic import)
    import(path.join(__dirname, 'bundle/bundle.js')).then(() =&gt; {
      expect(global.document.body.textContent).toEqual('Hello from Kotlin!');
    });
  });
});
github rickvandermey / angular-starterkit / server.ts View on Github external
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const {
	AppServerModuleNgFactory,
	LAZY_MODULE_MAP,
	ngExpressEngine,
	provideModuleMap,
} = require('./dist/server/main');

const PORT = process.env.PORT || 4201;
const DIST_FOLDER = join(process.cwd(), 'dist/browser');

// Provide support for window on the server
const template = readFileSync(join('dist/browser', 'index.html')).toString();
const fetch = require('node-fetch');
const win = domino.createWindow(template);

win.fetch = fetch;
global['window'] = win;
Object.defineProperty(win.document.body.style, 'transform', {
	value: () => {
		return {
			configurable: true,
			enumerable: true,
		};
	},
});
global['document'] = win.document;
global['CSS'] = null;
global['Prism'] = null;

// Config renderer
github kaisermann / aph / benchmark.js View on Github external
// We use 'domino' here because
// 'jsdom-global' doesn't work for some reason :()
global.window = require('domino').createWindow('', '')
global.document = global.window.document
require('colors')

const aph = require('./dist/aph.js')
const jQuery = require('jquery')
const cash = require('cash-dom')
const Zepto = require('zepto-node')(window)
const Benchmark = require('benchmark')

aph.fn.repeat = function (numberOfClones) {
  let repeatedElements = []
  let cachedElements = this.asArray()
  for (let i = numberOfClones; i--;) {
    repeatedElements = repeatedElements.concat(
      cachedElements.map(item => item.cloneNode())
    )
github tamiadev / tamia / config / mochasetup.js View on Github external
global.DEBUG = false;

global.expect = require('chai').expect;

global.window = require('domino').createWindow();
global.document = window.document;
global.navigator = window.navigator;
global.Element = window.Element;
global.getComputedStyle = window.getComputedStyle;

// dataset polyfill
// Based on https://gist.github.com/brettz9/4093766
var propDescriptor = {
	enumerable: true,
	get: function() {
		var toUpperCase = function(n0) {
			return n0.charAt(1).toUpperCase();
		};
		var getter = function() {
			return this;
		};
github mozilla-services / screenshots / server / src / contentcheck.js View on Github external
exports.checkContent = function (htmlString) {
  let window = domino.createWindow(htmlString);
  let errors = [];
  let els = window.document.getElementsByTagName("*");
  let elLength = els.length;
  for (let i=0; i
github mattgoldspink / grunt-sencha-dependencies / tasks / lib / DynamicAnalyserMockingExtSystem.js View on Github external
DynamicAnalyserMockingExtSystem.prototype.getDependencies = function () {
    var senchaCoreFile, contents, src;
    senchaCoreFile = this.mapClassToFile("Ext");
    this.filesLoadedSoFar.push(senchaCoreFile);
    contents = grunt.file.read(senchaCoreFile);
    // use domino to mock out our DOM api"s
    global.window = domino.createWindow("");
    global.document = window.document;
    defineGlobals(this.pageRoot);
    fixMissingDomApis();
    var Ext = safelyEvalFile(senchaCoreFile);
    this.defineExtGlobals();
    safelyEvalFile(this.pageRoot + "/" + this.appJsFilePath);
    this.filesLoadedSoFar.push(this.pageRoot + "/" + this.appJsFilePath);
    return this.filesLoadedSoFar;
};
github mattgoldspink / grunt-sencha-dependencies / tasks / lib / DynamicHeadlessBrowserEmulator.js View on Github external
DynamicHeadlessBrowserEmulator.prototype.getDependencies = function () {
    try {
        var senchaCoreFile = this.getSenchaCoreFile();
        // use domino to mock out our DOM api"s
        global.window = domino.createWindow("");
        global.document = window.document;
        defineGlobals(this.pageRoot);
        fixMissingDomApis();
        var Ext = safelyEvalFile(senchaCoreFile);
        this.defineExtGlobals(Ext);
        this.addPatchesToExtToRun(Ext);
        window.document.close();
        safelyEvalFile(this.pageRoot + "/" + this.appJsFilePath);
        if (!this.isTouch) {
            Ext.EventManager.deferReadyEvent = null;
            Ext.EventManager.fireReadyEvent();
        }
        return reorderFiles(
            Ext.Loader.history,
            this.getSenchaCoreFile(),
            this.pageRoot,
github mattgoldspink / grunt-sencha-dependencies / tasks / lib / SenchaDependencyChecker.js View on Github external
SenchaDependencyChecker.prototype.getDependencies = function () {
    var senchaCoreFile, contents, src;
    this.defineGlobals();
    senchaCoreFile = this.mapClassToFile('Ext');
    this.filesLoadedSoFar.push(senchaCoreFile);
    contents = grunt.file.read(senchaCoreFile);
    // use domino to mock out our DOM api's
    global.window = domino.createWindow('');
    global.document = window.document;
    try {
        eval(contents);
    } catch (e) {
        grunt.log.error("An unexpected error occured, please report a bug here " +
                    "https://github.com/mattgoldspink/grunt-sencha-dependencies/issues?state=open - " + e);
    }
    global.Ext = Ext;
    this.defineExtGlobals();
    if (!grunt.file.exists(this.appJsFilePath)) {
      grunt.log.error('Source file "' + filepath + '" not found.');
      return [];
    }
    eval(grunt.file.read(this.appJsFilePath));
    this.filesLoadedSoFar.push(this.appJsFilePath);
    //grunt.log.writeln("'" + this.classesSeenSoFar.asArray.join(',') + "'");
github ArndBrugman / huepi / huepi.js View on Github external
{
  var $;
  var XMLHttpRequest;

  if (typeof global !== 'undefined' &amp;&amp; typeof global.process !== 'undefined' &amp;&amp;
   Object.prototype.toString.call(global.process) === '[object process]') {
    $ = require('jquery')(require('domino').createWindow('huepi'));
    XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
    $.support.cors = true; // cross domain, Cross-origin resource sharing
    $.ajaxSettings.xhr = function() {
      return new XMLHttpRequest();
    };
  }
  module.exports = huepi;
} else if (typeof define === 'function' &amp;&amp; define.amd) {
  $ = require('jquery')(require('domino').createWindow('huepi'));
  XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
  $.support.cors = true; // cross domain, Cross-origin resource sharing
  $.ajaxSettings.xhr = function() {
    return new XMLHttpRequest();
  };
  define([], function() { return huepi; });
} else {
  $ = jQuery;
  window.huepi = huepi;
}

////////////////////////////////////////////////////////////////////////////////
//
// Private _BridgeCache Functions, Internal Used
//
//

domino

Server-side DOM implementation based on Mozilla's dom.js

BSD-2-Clause
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis

Popular domino functions