-
Notifications
You must be signed in to change notification settings - Fork 1
/
package.json
210 lines (210 loc) · 16.2 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
{
"name": "jsdom",
"version": "0.5.0",
"description": "A JavaScript implementation of the W3C DOM",
"keywords": [
"dom",
"w3c",
"html"
],
"maintainers": [
{
"name": "Elijah Insua",
"email": "tmpvar@gmail.com",
"url": "http://tmpvar.com"
},
{
"name": "Domenic Denicola",
"email": "domenic@domenicdenicola.com",
"url": "http://domenicdenicola.com"
}
],
"contributors": [
{
"name": "Vincent Greene",
"email": "ulteriorlife@gmail.com"
},
{
"name": "Dav Glass",
"email": "davglass@gmail.com"
},
{
"name": "Felix Gnass",
"email": "fgnass@gmail.com"
},
{
"name": "Charlie Robbins",
"email": "charlie.robbins@gmail.com"
},
{
"name": "Aria Stewart",
"email": "aredridel@nbtsc.org"
},
{
"name": "Matthew",
"email": "N.A.",
"url": "http://github.com/matthewpflueger/"
},
{
"name": "Olivier El Mekki",
"email": "unknown",
"url": "http://blog.olivier-elmekki.com/"
},
{
"name": "Shimon Dookdin",
"email": "helpmepro1@gmail.com"
},
{
"name": "Daniel Cassidy",
"email": "mail@danielcassidy.me.uk",
"url": "http://www.danielcassidy.me.uk/"
},
{
"name": "Sam Ruby",
"url": "http://intertwingly.net/blog/"
},
{
"name": "hij1nx",
"url": "http://github.com/hij1nx"
},
{
"name": "Yonathan Randolph",
"url": "http://github.com/yonran"
},
{
"name": "Martin Davis",
"url": "http://github.com/waslogic"
},
{
"name": "Andreas Lind Petersen",
"email": "andreas@one.com"
},
{
"name": "d-ash",
"url": "http://github.com/d-ash"
},
{
"name": "Robin Zhong",
"email": "fbzhong@gmail.com"
},
{
"name": "Alexander Flatter",
"email": "flatter@gmail.com"
},
{
"name": "Heng Liu",
"email": "liucougar@gmail.com"
},
{
"name": "Brian McDaniel",
"url": "http://github.com/brianmcd"
},
{
"name": "John Hurliman",
"email": "jhurliman@jhurliman.org"
},
{
"name": "Jimmy Mabey"
},
{
"name": "Gregory Tomlinson"
},
{
"name": "Jason Davies",
"url": "http://www.jasondavies.com/"
},
{
"name": "Josh Marshall",
"url": "http://www.ponderingtheobvious.com/"
},
{
"name": "Jason Priestley",
"url": "https://github.com/jhp"
},
{
"name": "Derek Lindahl",
"url": "https://github.com/dlindahl"
},
{
"name": "Chris Roebuck",
"email": "chris@quillu.com",
"url": "http://www.quillu.com"
},
{
"name": "Avi Deitcher",
"url": "https://github.com/deitch"
},
{
"name": "Nao Iizuka",
"email": "iizuka@kyu-mu.net",
"url": "https://github.com/iizukanao"
},
{
"name": "Peter Perenyi",
"url": "https://github.com/sinegar"
},
{
"name": "Tiago Rodrigues",
"email": "tmcrodrigues@gmail.com",
"url": "http://trodrigues.net"
},
{
"name": "Samori Gorse",
"email": "samorigorse@gmail.com",
"url": "http://github.com/shinuza"
},
{
"name": "John Roberts",
"email": "jroberts@logitech.com"
},
{
"name": "Chad Walker",
"email": "chad@chad-cat-lore-eddie.com",
"url": "https://github.com/chad3814"
}
],
"bugs": {
"email": "tmpvar@gmail.com",
"url": "http://github.com/tmpvar/jsdom/issues"
},
"licenses": [
{
"type": "MIT",
"url": "http://github.com/tmpvar/jsdom/blob/master/LICENSE.txt"
}
],
"repositories": [
{
"type": "git",
"url": "http://github.com/tmpvar/jsdom.git"
}
],
"implements": [
"http://www.w3.org/TR/REC-DOM-Level-1"
],
"dependencies": {
"htmlparser": "1.x",
"nwmatcher": ">=1.3.1",
"request": "2.x",
"cssom": "0.2.x",
"cssstyle": ">=0.2.3",
"contextify": "0.1.x"
},
"devDependencies": {
"nodeunit": ">=0.5.x",
"console.log": "*",
"html5": ">=0.3.8",
"optimist": "*"
},
"directories": {
"lib": "./lib/jsdom"
},
"scripts": {
"test": "node ./test/runner"
},
"main": "./lib/jsdom",
"readme": "# jsdom\n\nA JavaScript implementation of the W3C DOM.\n\n## Install\n\n```bash\n$ npm install jsdom\n```\n\nIf this gives you trouble with errors about installing Contextify, especially on Windows, see [below](#contextify).\n\n## Human contact\n\nsee: [mailing list](http://groups.google.com/group/jsdom)\n\n## Easymode\n\nBootstrapping 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.\n\nwith URL\n\n```js\n// Count all of the links from the nodejs build page\nvar jsdom = require(\"jsdom\");\n\njsdom.env(\n \"http://nodejs.org/dist/\",\n [\"http://code.jquery.com/jquery.js\"],\n function (errors, window) {\n console.log(\"there have been\", window.$(\"a\").length, \"nodejs releases!\");\n }\n);\n```\n\nor with raw HTML\n\n```js\n// Run some jQuery on a html fragment\nvar jsdom = require(\"jsdom\");\n\njsdom.env(\n '<p><a class=\"the-link\" href=\"https://github.com/tmpvar/jsdom\">jsdom\\'s Homepage</a></p>',\n [\"http://code.jquery.com/jquery.js\"],\n function(errors, window) {\n console.log(\"contents of a.the-link:\", window.$(\"a.the-link\").text());\n }\n);\n```\n\nor with a configuration object\n\n```js\n// Print all of the news items on hackernews\nvar jsdom = require(\"jsdom\");\n\njsdom.env({\n html: \"http://news.ycombinator.com/\",\n scripts: [\"http://code.jquery.com/jquery.js\"],\n done: function (errors, window) {\n var $ = window.$;\n console.log(\"HN Links\");\n $(\"td.title:not(:last) a\").each(function() {\n console.log(\" -\", $(this).text());\n });\n }\n});\n```\n\nor with raw JavaScript source\n\n```js\n// Print all of the news items on hackernews\nvar jsdom = require(\"jsdom\");\nvar fs = require(\"fs\");\nvar jquery = fs.readFileSync(\"./jquery.js\").toString();\n\njsdom.env({\n html: \"http://news.ycombinator.com/\",\n src: [jquery],\n done: function (errors, window) {\n var $ = window.$;\n console.log(\"HN Links\");\n $(\"td.title:not(:last) a\").each(function() {\n console.log(\" -\", $(this).text());\n });\n }\n});\n```\n\n### How it works\n`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`)\n\n```js\njsdom.env(html, [scripts], [config], callback);\n```\n\n- `html` (**required**): may be a URL, HTML fragment, or file.\n- `scripts` (**optional**): may contain files or URLs.\n- `config` (**optional**): see below.\n- `callback` (**required**): takes two arguments:\n - `errors`: an array of errors\n - `window`: a brand new window\n\n_example:_\n\n```js\njsdom.env(html, function (errors, window) {\n // free memory associated with the window\n window.close();\n});\n```\n\nIf you would like to specify a configuration object only:\n\n```js\njsdom.env(config);\n```\n\n- `config.html`: see `html` above.\n- `config.scripts`: see `scripts` above.\n- `config.src`: an array of JavaScript strings that will be evaluated against the resulting document. Similar to `scripts`, but it accepts JavaScript instead of paths/URLs.\n- `config.done`: see `callback` above.\n- `config.document`:\n - `referer`: the new document will have this referer\n - `cookie`: manually set a cookie value, e.g. `'key=value; expires=Wed, Sep 21 2011 12:00:00 GMT; path=/'`\n- `config.features` : see `Flexibility` section below. **Note**: the default feature set for jsdom.env does _not_ include fetching remote JavaScript and executing it. This is something that you will need to **carefully** enable yourself.\n\n## For the hardcore\n\nIf 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:\n\n```js\nvar jsdom = require(\"jsdom\").jsdom;\nvar doc = jsdom(markup, level, options);\nvar window = doc.createWindow();\n```\n\n- `markup` is an HTML/XML document to be parsed. You can also pass `null` or an undefined value to get a basic document with empty `<head>` and `<body>` tags. Document fragments are also supported (including `\"\"`), and will behave as sanely as possible (e.g. the resulting document will lack the `head`, `body` and `documentElement` properties if the corresponding elements aren't included).\n\n- `level` is `null` (which means level3) by default, but you can pass another level if you'd like.\n\n ```js\n var jsdom = require(\"jsdom\");\n var doc = jsdom.jsdom(\"<html><body></body></html>\", jsdom.level(1, \"core\"));\n ```\n\n- `options` see the **Flexibility** section below.\n\n### Flexibility\n\nOne 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 the `DOMImplementation` that every `Document` has, and may be tweaked in two ways:\n\n1. When you create a new `Document` using the jsdom builder (`require(\"jsdom\").jsdom()`)\n\n ```js\n var jsdom = require(\"jsdom\").jsdom;\n var doc = jsdom(\"<html><body></body></html>\", null, {\n features: {\n FetchExternalResources : [\"img\"]\n }\n });\n ```\n\n Do note, that this will only affect the document that is currently being created. All other documents will use the defaults specified below (see: Default Features).\n\n2. Before creating any documents, you can modify the defaults for all future documents:\n\n ```js\n require(\"jsdom\").defaultDocumentFeatures = {\n FetchExternalResources: [\"script\"],\n ProcessExternalResources: false\n };\n ```\n\n#### Default Features\n\nDefault 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.\n\n\n`FetchExternalResources`\n\n- _Default_: `[\"script\"]`\n- _Allowed_: `[\"script\", \"img\", \"css\", \"frame\", \"iframe\", \"link\"]` or `false`\n\nEnables/disables fetching files over the file system/HTTP.\n\n`ProcessExternalResources`\n\n- _Default_: `[\"script\"]`\n- _Allowed_: `[\"script\"]` or `false`\n\nDisabling this will disable script execution (currently only JavaScript).\n\n`SkipExternalResources`\n\n- _Default_: `false`\n- _Allowed_: `/url to be skipped/` or `false`\n- _Example_: `/http:\\/\\/example.org/js/bad\\.js/`\n\nDo not download and process resources with url matching a regular expression.\n\n### Canvas\n\njsdom includes support for using the [canvas](https://npmjs.org/package/canvas) package to extend any `<canvas>` elements with the canvas API. To make this work, you need to include canvas as a dependency in your project, as a peer of jsdom. If jsdom can find the canvas package, it will use it, but if it's not present, then `<canvas>` elements will behave like `<div>`s.\n\n## More Examples\n\n### Creating a document-less window\n\n```js\nvar jsdom = require(\"jsdom\");\nvar window = jsdom.createWindow();\n\nconsole.log(window.document); // output: undefined\n```\n\n### Creating a document\n\n```js\nvar jsdom = require(\"jsdom\");\nvar doc = new (jsdom.level(1, \"core\").Document)();\n\nconsole.log(doc.nodeName); // outputs: #document\n```\n\n### Creating a browser-like BOM/DOM/Window\n\n```js\nvar jsdom = require(\"jsdom\").jsdom;\nvar document = jsdom(\"<html><head></head><body>hello world</body></html>\");\nvar window = document.createWindow();\n\nconsole.log(window.document.innerHTML);\n// output: \"<html><head></head><body>hello world</body></html>\"\n\nconsole.log(window.innerWidth);\n// output: 1024\n\nconsole.log(typeof window.document.getElementsByClassName);\n// outputs: function\n```\n\n## jQueryify\n\n```js\nvar jsdom = require(\"jsdom\");\nvar window = jsdom.jsdom().createWindow();\n\njsdom.jQueryify(window, \"http://code.jquery.com/jquery.js\", function () {\n window.$(\"body\").append('<div class=\"testing\">Hello World, It works</div>');\n\n console.log(window.$(\".testing\").text());\n});\n```\n\n### Passing objects to scripts inside the page\n\n```js\nvar jsdom = require(\"jsdom\").jsdom;\nvar window = jsdom().createWindow();\n\nwindow.__myObject = { foo: \"bar\" };\n\nvar scriptEl = window.document.createElement(\"script\");\nscriptEl.src = \"anotherScript.js\";\nwindow.document.body.appendChild(scriptEl);\n\n// anotherScript.js will have the ability to read `window.__myObject`, even\n// though it originated in Node!\n```\n\n## Test Compliance:\n\n```\n level1/core 532/532 100%\n level1/html 238/238 100%\n level1/svg 527/527 100%\n level2/core 283/283 100%\n level2/html 700/700 100%\n level2/style 11/11 100%\n level2/extra 4/4 100%\n level2/events 24/24 100%\n level3/xpath 93/93 100%\n window/index 5/5 100%\n window/script 10/10 100%\n window/frame 14/14 100%\n sizzle/index 14/14 100%\n jsdom/index 86/86 100%\n jsonp/jsonp 1/1 100%\n browser/contextifyReplacement 4/4 100%\n browser/index 22/22 100%\n------------------------------------------------------\nTOTALS: 0/2568 failed; 100% success\nTIME: 32648ms\n```\n\n### Running the tests\n\nFirst you'll want to `npm install`. To run all the tests, use `npm test`, which just calls `node test/runner`.\n\nUsing `test/runner` directly, you can slice and dice which tests your want to run from different levels. Usage is as follows:\n\n```\ntest/runner --help\nRun the jsdom test suite\n\nOptions:\n-s, --suites suites that you want to run. ie: -s level1/core,1/html,html [string]\n-f, --fail-fast stop on the first failed test\n-h, --help show the help\n-t, --tests choose the test cases to run. ie: -t jquery\n```\n\n## Contextify\n\n[Contextify](https://npmjs.org/package/contextify) is a dependency of jsdom, used for running `<script>` tags within the\npage. In other words, it allows jsdom, which is run in Node.js, to run strings of JavaScript in an isolated environment\nthat pretends to be a browser environment instead of a server. You can see how this is an important feature.\n\nUnfortunately, doing this kind of magic requires C++. And in Node.js, using C++ from JavaScript means using \"native\nmodules.\" Native modules are compiled at installation time so that they work precisely for your machine; that is, you\ndon't download a contextify binary from npm, but instead build one locally after downloading the source from npm.\n\nFor Mac and Linux users, this is usually fine. Their systems come preinstalled with the necessaries for compiling C++.\nFor Windows users, however, things can be tricky. Thus, one of the most common problems with jsdom is trying to use it\non Windows without the proper compilation tools installed. Here's what you need to compile Contextify, and thus to\ninstall jsdom, on Windows:\n\n* A recent copy of the *x86* version of [Node.js for Windows](http://nodejs.org/download/), *not* the x64 version.\n* A copy of [Visual C++ 2010 Express](http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express).\n* A copy of [Python 2.7](http://www.python.org/download/), installed in the default location of `C:\\Python27`.\n\nThere are some slight modifications to this that can work; for example full versions of Visual Studio usually work, and\nsometimes you can even get an x64 version of Node.js working too. But it's tricky, so start with the basics!\n",
"readmeFilename": "README.md",
"_id": "jsdom@0.5.0",
"_from": "jsdom@"
}