JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q44799F
  • License MIT

This module exports a cross-platform window instance object.

Package Exports

  • xwindow
  • xwindow/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (xwindow) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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)