Explicitly mention lack of `Node` in `node.js` environments

pull/415/head
Gijs 7 years ago committed by GitHub
parent 807bf05aa3
commit 0a30527c85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -42,6 +42,15 @@ This `article` object will contain the following properties:
If you're using Readability on the web, you will likely be able to use a `document` reference from elsewhere (e.g. fetched via XMLHttpRequest, in a same-origin `<iframe>` you have access to, etc.). Otherwise, you would need to construct such an object using a DOM parser such as [jsdom](https://github.com/tmpvar/jsdom). While this repository contains a parser of its own (`JSDOMParser`), that is restricted to reading XML-compatible markup and therefore we do not recommend it for general use.
Until [#346](https://github.com/mozilla/readability/issues/346) is fixed, if you're using `jsdom` and `node` (rather than running in a browser), you will need to also ensure a global `Node` object is available for `Readability` to use, e.g. like so:
```javascript
...
var dom = new JSDOM(html, OPTIONS);
Node = dom.window.Node
var article = new Readability(uri, dom).parse();
```
### Optional
Readability's `parse()` works by modifying the DOM. This removes some elements in the web page. You could avoid this by passing the clone of the `document` object while creating a `Readability` object.

Loading…
Cancel
Save