jsdom-global
Advanced tools
Comparing version 1.7.0 to 2.0.0
@@ -0,1 +1,9 @@ | ||
## [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] | ||
@@ -64,1 +72,6 @@ > Mar 21, 2016 | ||
[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 | ||
[#2]: https://github.com/rstacruz/jsdom-global/issues/2 | ||
[@kenjiru]: https://github.com/kenjiru | ||
[@ngryman]: https://github.com/ngryman |
23
index.js
@@ -5,3 +5,3 @@ /* | ||
var html = '<!doctype html><html><head><meta charset="utf-8">' + | ||
var defaultHtml = '<!doctype html><html><head><meta charset="utf-8">' + | ||
'</head><body></body></html>' | ||
@@ -15,16 +15,11 @@ | ||
module.exports = function globalJsdom (func) { | ||
if (typeof func === 'function') { | ||
try { | ||
var cleanup = globalize() | ||
return func() | ||
} finally { | ||
cleanup() | ||
} | ||
} else { | ||
return globalize() | ||
module.exports = function globalJsdom (html, options) { | ||
if (html === undefined) { | ||
html = defaultHtml | ||
} | ||
} | ||
function globalize () { | ||
if (options === undefined) { | ||
options = {} | ||
} | ||
// Idempotency | ||
@@ -40,3 +35,3 @@ if (global.navigator && | ||
var jsdom = require('jsdom') | ||
var document = jsdom.jsdom(html) | ||
var document = jsdom.jsdom(html, options) | ||
var window = document.defaultView | ||
@@ -43,0 +38,0 @@ var keys = [] |
{ | ||
"name": "jsdom-global", | ||
"version": "1.7.0", | ||
"version": "2.0.0", | ||
"description": "Enable DOM in Node.js", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "node test.js && standard" | ||
}, | ||
@@ -27,5 +27,6 @@ "repository": { | ||
"devDependencies": { | ||
"jsdom": "7.2.2", | ||
"jsdom": "9.0.0", | ||
"standard": "7.0.1", | ||
"tape": "4.4.0" | ||
} | ||
} |
@@ -24,3 +24,3 @@ # jsdom-global | ||
```js | ||
require('jsdom-global')() | ||
require('jsdom-global')(html, options) | ||
@@ -31,2 +31,5 @@ // you can now use the DOM | ||
Both `html` and `options` parameters are optional. | ||
Check the [jsdom.jsdom()][] documentation for valid values for the `options` parameter. | ||
To clean up after itself, just invoke the function it returns. | ||
@@ -76,2 +79,3 @@ | ||
[mocha]: https://mochajs.org/ | ||
[jsdom.jsdom()]: https://github.com/tmpvar/jsdom/#for-the-hardcore-jsdomjsdom | ||
@@ -78,0 +82,0 @@ ## Browserify |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8115
127
3
72