0.3.0 • Published 11 months ago

xwindow v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

xwindow

NPM Version Node.js CI Coverage Status

This module exports a cross-platform window instance object.

  • In the browser it just exports the global window object
  • In NodeJS, it exports the newly created JSDOM window instance

Thus, DOM-dependent modules become compatible and can be used both in NodeJS and in the browser.

Installation

npm install xwindow

Usage

ES2015

import window from 'xwindow'

CommonJS

const window = require('xwindow')

Example

import window from 'xwindow'

const { document, CustomEvent, DocumentFragment, Node } = window

const node = document.createElement('div')
const fragment = new DocumentFragment

fragment.append(node)

if(node.nodeType === Node.ELEMENT_NODE) {
  node.dispatchEvent(new CustomEvent('answer', { detail : 42 }))
}

License

The MIT License (MIT)

0.3.0

11 months ago

0.2.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

2.0.0

3 years ago