$
This commit is contained in:
1
node_modules/jsdom-global/.npmignore
generated
vendored
Normal file
1
node_modules/jsdom-global/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
6
node_modules/jsdom-global/.travis.yml
generated
vendored
Normal file
6
node_modules/jsdom-global/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '7'
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
113
node_modules/jsdom-global/HISTORY.md
generated
vendored
Normal file
113
node_modules/jsdom-global/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
## [v3.0.2]
|
||||
> May 8, 2017
|
||||
|
||||
- [#17] - Fix issue with `Image`. ([@jtag05])
|
||||
- [#16] - Mark jsdom as a peer dependency.
|
||||
|
||||
[v3.0.2]: https://github.com/rstacruz/jsdom-global/compare/v3.0.0...v3.0.2
|
||||
|
||||
## [v3.0.0]
|
||||
> May 8, 2017
|
||||
|
||||
- [#23] - jsdom-global now requires jsdom v10. ([@GinjiBan])
|
||||
|
||||
[v3.0.0]: https://github.com/rstacruz/jsdom-global/compare/v2.1.1...v3.0.0
|
||||
|
||||
## [v2.1.1]
|
||||
> Dec 24, 2016
|
||||
|
||||
- [#11] - Fix issues with XMLHttpRequest.
|
||||
|
||||
[v2.1.1]: https://github.com/rstacruz/jsdom-global/compare/v2.1.0...v2.1.1
|
||||
|
||||
## [v2.1.0]
|
||||
> Aug 22, 2016
|
||||
|
||||
- [#6], [#7] - Fix support for jsdom 9.4.0.
|
||||
|
||||
[v2.1.0]: https://github.com/rstacruz/jsdom-global/compare/v2.0.0...v2.1.0
|
||||
|
||||
## [v2.0.0]
|
||||
> May 13, 2016
|
||||
|
||||
- [#3] - Allow overriding `html` and `options` being passed to jsdom. ([#5], [@kenjiru])
|
||||
- Deprecate the undocumented (and never-used) feature of calling `jsdom(function)`.
|
||||
|
||||
[v2.0.0]: https://github.com/rstacruz/jsdom-global/compare/v1.7.0...v2.0.0
|
||||
|
||||
## [v1.7.0]
|
||||
> Mar 21, 2016
|
||||
|
||||
- Implement `jsdom-global/register` for use in simpler cases.
|
||||
|
||||
[v1.7.0]: https://github.com/rstacruz/jsdom-global/compare/v1.6.2...v1.7.0
|
||||
|
||||
## [v1.6.2]
|
||||
> Feb 22, 2016
|
||||
|
||||
- Fix typo in browser.js.
|
||||
|
||||
[v1.6.2]: https://github.com/rstacruz/jsdom-global/compare/v1.6.1...v1.6.2
|
||||
|
||||
## [v1.6.1]
|
||||
> Jan 15, 2016
|
||||
|
||||
- Make `jsdomGlobal()` idempotent - that is, you may call it twice and expect
|
||||
the same result without any side effects.
|
||||
|
||||
[v1.6.1]: https://github.com/rstacruz/jsdom-global/compare/v1.5.0...v1.6.1
|
||||
|
||||
## [v1.5.0]
|
||||
> Jan 12, 2016
|
||||
|
||||
- Remove tape integration... we don't need it.
|
||||
|
||||
[v1.5.0]: https://github.com/rstacruz/jsdom-global/compare/v1.4.0...v1.5.0
|
||||
|
||||
## [v1.4.0]
|
||||
> Jan 12, 2016
|
||||
|
||||
- `tape`: Shows navigator userAgent in tape output.
|
||||
|
||||
[v1.4.0]: https://github.com/rstacruz/jsdom-global/compare/v1.3.0...v1.4.0
|
||||
|
||||
## [v1.3.0]
|
||||
> Jan 11, 2016
|
||||
|
||||
- Add browserify support.
|
||||
|
||||
[v1.3.0]: https://github.com/rstacruz/jsdom-global/compare/v1.2.0...v1.3.0
|
||||
|
||||
## [v1.2.0]
|
||||
> Jan 11, 2016
|
||||
|
||||
- Fix compatibility with legacy Node.js versions.
|
||||
|
||||
[v1.2.0]: https://github.com/rstacruz/jsdom-global/compare/v1.1.0...v1.2.0
|
||||
|
||||
## [v1.1.0]
|
||||
> Jan 11, 2016
|
||||
|
||||
- Add `cleanup()`.
|
||||
|
||||
[v1.1.0]: https://github.com/rstacruz/jsdom-global/compare/v1.0.0...v1.1.0
|
||||
|
||||
## [v1.0.0]
|
||||
> Jan 11, 2016
|
||||
|
||||
- Initial release.
|
||||
|
||||
[v1.0.0]: https://github.com/rstacruz/jsdom-global/tree/v1.0.0
|
||||
[#3]: https://github.com/rstacruz/jsdom-global/issues/3
|
||||
[#5]: https://github.com/rstacruz/jsdom-global/issues/5
|
||||
[#6]: https://github.com/rstacruz/jsdom-global/issues/6
|
||||
[#7]: https://github.com/rstacruz/jsdom-global/issues/7
|
||||
[#2]: https://github.com/rstacruz/jsdom-global/issues/2
|
||||
[#11]: https://github.com/rstacruz/jsdom-global/issues/11
|
||||
[#16]: https://github.com/rstacruz/jsdom-global/issues/16
|
||||
[#17]: https://github.com/rstacruz/jsdom-global/issues/17
|
||||
[#23]: https://github.com/rstacruz/jsdom-global/issues/23
|
||||
[@kenjiru]: https://github.com/kenjiru
|
||||
[@ngryman]: https://github.com/ngryman
|
||||
[@GinjiBan]: https://github.com/GinjiBan
|
||||
[@jtag05]: https://github.com/jtag05
|
141
node_modules/jsdom-global/README.md
generated
vendored
Normal file
141
node_modules/jsdom-global/README.md
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
# jsdom-global
|
||||
|
||||
> Enables DOM in Node.js
|
||||
|
||||
jsdom-global will inject `document`, `window` and other DOM API into your Node.js environment. Useful for running, in Node.js, tests that are made for browsers.
|
||||
|
||||
[](https://travis-ci.org/rstacruz/jsdom-global "See test builds")
|
||||
|
||||
## Install
|
||||
|
||||
Requires [jsdom][].
|
||||
|
||||
```
|
||||
npm install --save-dev --save-exact jsdom jsdom-global
|
||||
```
|
||||
|
||||
[jsdom]: https://github.com/tmpvar/jsdom
|
||||
|
||||
## Note
|
||||
|
||||
jsdom-global now requires jsdom v10 or above. If you need jsdom v9 and below, use the previous version (`jsdom-global@2`).
|
||||
|
||||
## Usage
|
||||
|
||||
Just invoke it to turn your Node.js environment into a DOM environment.
|
||||
|
||||
```js
|
||||
require('jsdom-global')()
|
||||
|
||||
// you can now use the DOM
|
||||
document.body.innerHTML = 'hello'
|
||||
```
|
||||
|
||||
You may also pass parameters to jsdomGlobal() like so: `require('jsdom-global')(html, options)`.
|
||||
Check the [jsdom.jsdom()][] documentation for valid values for the `options` parameter.
|
||||
|
||||
To clean up after itself, just invoke the function it returns.
|
||||
|
||||
```js
|
||||
var cleanup = require('jsdom-global')()
|
||||
|
||||
// do things
|
||||
|
||||
cleanup()
|
||||
```
|
||||
|
||||
## Tape
|
||||
|
||||
In [tape][], run it before your other tests.
|
||||
|
||||
```js
|
||||
require('jsdom-global')()
|
||||
|
||||
test('your tests', (t) => {
|
||||
/* and so on... */
|
||||
})
|
||||
```
|
||||
|
||||
## Mocha
|
||||
|
||||
__Simple:__ Use Mocha's `--require` option. Add this to the `test/mocha.opts` file (create it if it doesn't exist)
|
||||
|
||||
```
|
||||
-r jsdom-global/register
|
||||
```
|
||||
|
||||
__Advanced:__ For finer control, you can instead add it via [mocha]'s `before` and `after` hooks.
|
||||
|
||||
```js
|
||||
before(function () {
|
||||
this.jsdom = require('jsdom-global')()
|
||||
})
|
||||
|
||||
after(function () {
|
||||
this.jsdom()
|
||||
})
|
||||
```
|
||||
|
||||
[tape]: https://github.com/substack/tape
|
||||
[mocha]: https://mochajs.org/
|
||||
[jsdom.jsdom()]: https://github.com/tmpvar/jsdom/#for-the-hardcore-jsdomjsdom
|
||||
|
||||
## ES2015
|
||||
|
||||
If you prefer to use `import` rather than `require`, you might want to use `jsdom-global/register` instead. Place it on top of your other import calls.
|
||||
|
||||
```js
|
||||
import 'jsdom-global/register'
|
||||
import React from 'react'
|
||||
import jQuery from 'jquery'
|
||||
// ...
|
||||
```
|
||||
|
||||
## Browserify
|
||||
|
||||
If you use [Browserify] on your tests (eg: [smokestack], [tape-run], [budo], [hihat], [zuul], and so on), doing `require('jsdom-global')()` is a noop. In practice, this means you can use jsdom-global even if your tests are powered by browserify, and your test will now work in both the browser and Node.
|
||||
|
||||
[zuul]: https://www.npmjs.com/package/zuul
|
||||
[tape-run]: https://www.npmjs.com/package/tape-run
|
||||
[budo]: https://github.com/mattdesl/budo
|
||||
[hihat]: https://www.npmjs.com/package/hihat
|
||||
[smokestack]: https://www.npmjs.com/package/smokestack
|
||||
|
||||
* Writing your tests (`test.js`):
|
||||
|
||||
```js
|
||||
require('jsdom-global')()
|
||||
|
||||
// ...do your tests here
|
||||
```
|
||||
|
||||
* Running it with [smokestack]:
|
||||
|
||||
```sh
|
||||
browserify test.js | smokestack # run in a browser
|
||||
node test.js # or the console
|
||||
browserify test.js --no-bundle-external # also works (but why bother?)
|
||||
```
|
||||
|
||||
* Running it with Babel ([babelify] or [babel-cli]):
|
||||
|
||||
```sh
|
||||
browserify test.js -t babelify | smokestack # run in a browser (with babel)
|
||||
babel-node test.js # or the console
|
||||
```
|
||||
|
||||
[Browserify]: http://browserify.org/
|
||||
[babel-cli]: https://babeljs.io/docs/usage/cli/
|
||||
[babelify]: https://github.com/babel/babelify
|
||||
|
||||
## Thanks
|
||||
|
||||
**jsdom-global** © 2016+, Rico Sta. Cruz. Released under the [MIT] License.<br>
|
||||
Authored and maintained by Rico Sta. Cruz with help from contributors ([list][contributors]).
|
||||
|
||||
> [ricostacruz.com](http://ricostacruz.com) ·
|
||||
> GitHub [@rstacruz](https://github.com/rstacruz) ·
|
||||
> Twitter [@rstacruz](https://twitter.com/rstacruz)
|
||||
|
||||
[MIT]: http://mit-license.org/
|
||||
[contributors]: http://github.com/rstacruz/jsdom-global/contributors
|
10
node_modules/jsdom-global/browser.js
generated
vendored
Normal file
10
node_modules/jsdom-global/browser.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* this is what browserify will use if you use browserify on your tests.
|
||||
* no need to bootstrap a DOM environment in a browser.
|
||||
*/
|
||||
|
||||
module.exports = function () {
|
||||
return noop
|
||||
}
|
||||
|
||||
function noop () { }
|
46
node_modules/jsdom-global/index.js
generated
vendored
Normal file
46
node_modules/jsdom-global/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* enables jsdom globally.
|
||||
*/
|
||||
|
||||
var KEYS = require('./keys')
|
||||
|
||||
var defaultHtml = '<!doctype html><html><head><meta charset="utf-8">' +
|
||||
'</head><body></body></html>'
|
||||
|
||||
module.exports = function globalJsdom (html, options) {
|
||||
if (html === undefined) {
|
||||
html = defaultHtml
|
||||
}
|
||||
|
||||
if (options === undefined) {
|
||||
options = {}
|
||||
}
|
||||
|
||||
// Idempotency
|
||||
if (global.navigator &&
|
||||
global.navigator.userAgent &&
|
||||
global.navigator.userAgent.indexOf('Node.js') > -1 &&
|
||||
global.document &&
|
||||
typeof global.document.destroy === 'function') {
|
||||
return global.document.destroy
|
||||
}
|
||||
|
||||
var jsdom = require('jsdom')
|
||||
var document = new jsdom.JSDOM(html, options)
|
||||
var window = document.window
|
||||
|
||||
KEYS.forEach(function (key) {
|
||||
global[key] = window[key]
|
||||
})
|
||||
|
||||
global.document = window.document
|
||||
global.window = window
|
||||
window.console = global.console
|
||||
document.destroy = cleanup
|
||||
|
||||
function cleanup () {
|
||||
KEYS.forEach(function (key) { delete global[key] })
|
||||
}
|
||||
|
||||
return cleanup
|
||||
}
|
189
node_modules/jsdom-global/keys.js
generated
vendored
Normal file
189
node_modules/jsdom-global/keys.js
generated
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
// See jsdom's lib/jsdom/living/index.js
|
||||
var LIVING_KEYS = [
|
||||
'DOMException',
|
||||
'NamedNodeMap',
|
||||
'Attr',
|
||||
'Node',
|
||||
'Element',
|
||||
'DocumentFragment',
|
||||
'HTMLDocument',
|
||||
'Document',
|
||||
'CharacterData',
|
||||
'Comment',
|
||||
'DocumentType',
|
||||
'DOMImplementation',
|
||||
'ProcessingInstruction',
|
||||
'Image',
|
||||
'Text',
|
||||
'Event',
|
||||
'CustomEvent',
|
||||
'MessageEvent',
|
||||
'ErrorEvent',
|
||||
'HashChangeEvent',
|
||||
'PopStateEvent',
|
||||
'UIEvent',
|
||||
'MouseEvent',
|
||||
'KeyboardEvent',
|
||||
'TouchEvent',
|
||||
'ProgressEvent',
|
||||
'EventTarget',
|
||||
'Location',
|
||||
'History',
|
||||
'HTMLElement',
|
||||
'HTMLAnchorElement',
|
||||
'HTMLAppletElement',
|
||||
'HTMLAreaElement',
|
||||
'HTMLAudioElement',
|
||||
'HTMLBaseElement',
|
||||
'HTMLBodyElement',
|
||||
'HTMLBRElement',
|
||||
'HTMLButtonElement',
|
||||
'HTMLCanvasElement',
|
||||
'HTMLDataElement',
|
||||
'HTMLDataListElement',
|
||||
'HTMLDialogElement',
|
||||
'HTMLDirectoryElement',
|
||||
'HTMLDivElement',
|
||||
'HTMLDListElement',
|
||||
'HTMLEmbedElement',
|
||||
'HTMLFieldSetElement',
|
||||
'HTMLFontElement',
|
||||
'HTMLFormElement',
|
||||
'HTMLFrameElement',
|
||||
'HTMLFrameSetElement',
|
||||
'HTMLHeadingElement',
|
||||
'HTMLHeadElement',
|
||||
'HTMLHRElement',
|
||||
'HTMLHtmlElement',
|
||||
'HTMLIFrameElement',
|
||||
'HTMLImageElement',
|
||||
'HTMLInputElement',
|
||||
'HTMLLabelElement',
|
||||
'HTMLLegendElement',
|
||||
'HTMLLIElement',
|
||||
'HTMLLinkElement',
|
||||
'HTMLMapElement',
|
||||
'HTMLMediaElement',
|
||||
'HTMLMenuElement',
|
||||
'HTMLMetaElement',
|
||||
'HTMLMeterElement',
|
||||
'HTMLModElement',
|
||||
'HTMLObjectElement',
|
||||
'HTMLOListElement',
|
||||
'HTMLOptGroupElement',
|
||||
'HTMLOptionElement',
|
||||
'HTMLOutputElement',
|
||||
'HTMLParagraphElement',
|
||||
'HTMLParamElement',
|
||||
'HTMLPreElement',
|
||||
'HTMLProgressElement',
|
||||
'HTMLQuoteElement',
|
||||
'HTMLScriptElement',
|
||||
'HTMLSelectElement',
|
||||
'HTMLSourceElement',
|
||||
'HTMLSpanElement',
|
||||
'HTMLStyleElement',
|
||||
'HTMLTableCaptionElement',
|
||||
'HTMLTableCellElement',
|
||||
'HTMLTableColElement',
|
||||
'HTMLTableDataCellElement',
|
||||
'HTMLTableElement',
|
||||
'HTMLTableHeaderCellElement',
|
||||
'HTMLTimeElement',
|
||||
'HTMLTitleElement',
|
||||
'HTMLTableRowElement',
|
||||
'HTMLTableSectionElement',
|
||||
'HTMLTemplateElement',
|
||||
'HTMLTextAreaElement',
|
||||
'HTMLTrackElement',
|
||||
'HTMLUListElement',
|
||||
'HTMLUnknownElement',
|
||||
'HTMLVideoElement',
|
||||
'StyleSheet',
|
||||
'MediaList',
|
||||
'CSSStyleSheet',
|
||||
'CSSRule',
|
||||
'CSSStyleRule',
|
||||
'CSSMediaRule',
|
||||
'CSSImportRule',
|
||||
'CSSStyleDeclaration',
|
||||
'StyleSheetList',
|
||||
'XPathException',
|
||||
'XPathExpression',
|
||||
'XPathResult',
|
||||
'XPathEvaluator',
|
||||
'HTMLCollection',
|
||||
'NodeFilter',
|
||||
'NodeIterator',
|
||||
'NodeList',
|
||||
'Blob',
|
||||
'File',
|
||||
'FileList',
|
||||
'FormData',
|
||||
'XMLHttpRequest',
|
||||
'XMLHttpRequestEventTarget',
|
||||
'XMLHttpRequestUpload',
|
||||
'DOMTokenList',
|
||||
'URL'
|
||||
]
|
||||
|
||||
var OTHER_KEYS = [
|
||||
'addEventListener',
|
||||
'alert',
|
||||
'atob',
|
||||
'blur',
|
||||
'btoa',
|
||||
/* 'clearInterval', */
|
||||
/* 'clearTimeout', */
|
||||
'close',
|
||||
'confirm',
|
||||
/* 'console', */
|
||||
'createPopup',
|
||||
'dispatchEvent',
|
||||
'document',
|
||||
'focus',
|
||||
'frames',
|
||||
'getComputedStyle',
|
||||
'history',
|
||||
'innerHeight',
|
||||
'innerWidth',
|
||||
'length',
|
||||
'location',
|
||||
'moveBy',
|
||||
'moveTo',
|
||||
'name',
|
||||
'navigator',
|
||||
'open',
|
||||
'outerHeight',
|
||||
'outerWidth',
|
||||
'pageXOffset',
|
||||
'pageYOffset',
|
||||
'parent',
|
||||
'postMessage',
|
||||
'print',
|
||||
'prompt',
|
||||
'removeEventListener',
|
||||
'resizeBy',
|
||||
'resizeTo',
|
||||
'screen',
|
||||
'screenLeft',
|
||||
'screenTop',
|
||||
'screenX',
|
||||
'screenY',
|
||||
'scroll',
|
||||
'scrollBy',
|
||||
'scrollLeft',
|
||||
'scrollTo',
|
||||
'scrollTop',
|
||||
'scrollX',
|
||||
'scrollY',
|
||||
'self',
|
||||
/* 'setInterval', */
|
||||
/* 'setTimeout', */
|
||||
'stop',
|
||||
/* 'toString', */
|
||||
'top',
|
||||
'window'
|
||||
]
|
||||
|
||||
module.exports = LIVING_KEYS.concat(OTHER_KEYS)
|
33
node_modules/jsdom-global/package.json
generated
vendored
Normal file
33
node_modules/jsdom-global/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "jsdom-global",
|
||||
"description": "Enable DOM in Node.js",
|
||||
"version": "3.0.2",
|
||||
"author": "Rico Sta. Cruz <rico@ricostacruz.com>",
|
||||
"browser": "browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/rstacruz/jsdom-global/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jsdom": "~10.0.0",
|
||||
"standard": "~10.0.2",
|
||||
"tape": "~4.6.3"
|
||||
},
|
||||
"homepage": "https://github.com/rstacruz/jsdom-global#readme",
|
||||
"keywords": [
|
||||
"dom",
|
||||
"jsdom",
|
||||
"test"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"peerDependencies": {
|
||||
"jsdom": ">=10.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rstacruz/jsdom-global.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test.js && standard"
|
||||
}
|
||||
}
|
1
node_modules/jsdom-global/register.js
generated
vendored
Normal file
1
node_modules/jsdom-global/register.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
require('./index')()
|
22
node_modules/jsdom-global/test.js
generated
vendored
Normal file
22
node_modules/jsdom-global/test.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
var test = require('tape')
|
||||
var jsdom
|
||||
|
||||
test('jsdom', function (t) {
|
||||
jsdom = require('./index')()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('dom', function (t) {
|
||||
var div = document.createElement('div')
|
||||
div.innerHTML = 'hello'
|
||||
document.body.appendChild(div)
|
||||
t.equal(document.querySelector('body').innerHTML, '<div>hello</div>', 'dom works')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
jsdom()
|
||||
t.ok(typeof global.document === 'undefined', 'cleaned document')
|
||||
t.ok(typeof global.alert === 'undefined', 'cleaned alert')
|
||||
t.end()
|
||||
})
|
Reference in New Issue
Block a user