Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

readme fixes, changed request dep to >=1.0.0 for pre-node 0.3.6 support

  • Loading branch information...
commit 13a80d673730f7afd744e9245c56448645b4a01e 1 parent f1a5ecb
@tmpvar authored
Showing with 53 additions and 49 deletions.
  1. +52 −48 README.md
  2. +1 −1  package.json
View
100 README.md
@@ -1,15 +1,8 @@
-# jsdom
+# jsdom 0.2.0
A javascript implementation of the W3C DOM.
-W3C Test Compliance:
-
- - DOM Level 1 html/svg/xml (100%)
- - DOM Level 2 html/events/core (100%)
- - DOM Level 3 core (14%)
-
-
-# Install
+## Install
npm install jsdom
@@ -19,11 +12,9 @@ or
cd jsdom
npm link .
-# Easymode
+## Easymode
-Bootstrapping a DOM generally a difficult process involving many error prone steps.
-We didn't want jsdom to fall into the same trap, and that is why a new method, jsdom.env(),
-has been added in jsdom 0.2.0 which should make everyone's lives easier.
+Bootstrapping a DOM is generally a difficult process involving many error prone steps. We didn't want jsdom to fall into the same trap and that is why a new method, `jsdom.env()`, has been added in jsdom 0.2.0 which should make everyone's lives easier.
// Count all of the links from the nodejs build page
var jsdom = require("jsdom");
@@ -45,8 +36,19 @@ or with raw html
console.log("contents of a.the-link:", window.$("a.the-link").text());
});
-## How it works
- `jsdom.env` is built for ease of use, which is rare in the dom environment! Since the web has some absolutely horrible javascript on it, as of jsdom 0.2.0 `jsdom.env` will not process external resources (scripts, images, etc). If you want to process the javascript use one of the methods below (`jsdom.jsdom` or `jsdom.jQueryify`)
+or with a configuration object
+
+ // Run some jQuery on a html fragment
+ var jsdom = require('jsdom');
+
+ jsdom.env('http://news.ycombinator.com/', [
+ 'http://code.jquery.com/jquery-1.5.min.js'
+ ], function(errors, window) {
+ $()
+ });
+
+### How it works
+ `jsdom.env` is built for ease of use, which is rare in the world of the DOM! Since the web has some absolutely horrible javascript on it, as of jsdom 0.2.0 `jsdom.env` will not process external resources (scripts, images, etc). If you want to process the javascript use one of the methods below (`jsdom.jsdom` or `jsdom.jQueryify`)
jsdom.env(html, [scripts], [options], callback)
@@ -72,23 +74,24 @@ If you would like to specify a configuration object
- config.scripts : see `scripts` above
- config.done : see `callback` above
-# For the hardcore
+## For the hardcore
-If you want to spawn a document/window and specify all sorts of options this is the section for you. This section covers the jsdom.jsdom method:
+If you want to spawn a document/window and specify all sorts of options this is the section for you. This section covers the `jsdom.jsdom` method:
- var jsdom = require("jsdom").jsdom
- window = jsdom(html, level, options)
+ var jsdom = require("jsdom").jsdom,
+ doc = jsdom(markup, level, options),
+ window = doc.createWindow();
- - `html` is a full html document
- - `level` is `null` (which means level3) by default, but you can pas another level if you'd like.
+ - `markup` is a full html/xml document to be parsed
+ - `level` is `null` (which means level3) by default, but you can pass another level if you'd like.
var jsdom = require('jsdom'),
- doc = jsdom.jsdom('<html><body></body></html>', jsdom.dom.level1.core)
+ doc = jsdom.jsdom('<html><body></body></html>', jsdom.dom.level1.core)
- `options` see the **Flexibility** section below
-## Flexibility
+### Flexibility
One of the goals of jsdom is to be as minimal and light as possible. This section details how
someone can change the behavior of `Document`s on the fly. These features are baked into
@@ -117,43 +120,36 @@ will use the defaults specified below (see: Default Features)
-### Default Features
+#### Default Features
Default features are extremely important for jsdom as they lower the configuration requirement and present developers a set of consistent default behaviors. The following sections detail the available features, their defaults, and the values that jsdom uses.
-#### FetchExternalResources
-**Default**: ['script']
-
-**Allowed**: ['script', 'img', 'css', 'frame', 'link'] or false
+`FetchExternalResources`
+_Default_: ['script']
+_Allowed_: ['script', 'img', 'css', 'frame', 'link'] or false
Enables/Disables fetching files over the filesystem/http
-#### ProcessExternalResources
-**Default** ['script']
-
-**Allowed** ['script'] or false
-
-By default, jsdom executes text content in a SCRIPT and the text retrieved from fetching data from a SCRIPT.src. Turning it off will disable script execution (currently only javascript)
-
-Support for frames is in the works
-
-
-#### MutationEvents
-**Default** : '2.0'
+`ProcessExternalResources`
+_default_: ['script']
+_allowed_: ['script'] or false
+
+Disabling this will disable script execution (currently only javascript).
-**Allowed** : '2.0' or false
+`MutationEvents`
+_default_: '2.0'
+_allowed_ : '2.0' or false
Initially enabled to be up to spec. Disable this if you do not need mutation events and want jsdom to be a bit more efficient.
-#### QuerySelector
-**Default** : false
-
-**Allowed** : true
+**Note**: `ProcessExternalResources` requires this to be enabled
-This feature is backed by [sizzle][]
+`QuerySelector`
+_default_ : false
+_allowed_ : true
-[sizzle][] but currently causes problems with some libraries. Enable if you want `document.querySelector` and friends, but be aware that many libraries feature detect for this, and it may cause you a bit of trouble.
+This feature is backed by [sizzle][] but currently causes problems with some libraries. Enable this if you want `document.querySelector` and friends, but be aware that many libraries feature detect for this, and it may cause you a bit of trouble.
[sizzle]:http://sizzlejs.com/
@@ -199,11 +195,19 @@ This feature is backed by [sizzle][]
console.log(window.$('.testing').text());
});
+# W3C Test Compliance:
+
+ - DOM Level 1 html/svg/xml (100%)
+ - DOM Level 2 html/events/core (100%)
+ - DOM Level 3 core (14%)
+
+see: [testlog][] for w3/jsdom test compliance
+
# More
see: [mailing list][]
-see: [testlog][] for w3/jsdom test compliance
+
see: [plan][] for roadmap and thoughts about this project
View
2  package.json
@@ -80,7 +80,7 @@
],
"dependencies": {
"htmlparser": ">=1.7.0",
- "request" : ">=1.9.0"
+ "request" : ">=1.0.0"
},
"devDependiencies" : {
"mjsunit.runner" : ">=0.1.0"
Please sign in to comment.
Something went wrong with that request. Please try again.