{
  "name": "jsdom",
  "version": "0.11.1",
  "description": "A JavaScript implementation of the DOM and HTML standards",
  "keywords": [
    "dom",
    "html",
    "whatwg",
    "w3c"
  ],
  "maintainers": [
    {
      "name": "Elijah Insua",
      "email": "tmpvar@gmail.com",
      "url": "http://tmpvar.com"
    },
    {
      "name": "Domenic Denicola",
      "url": "http://domenic.me/"
    }
  ],
  "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"
    },
    {
      "name": "Zach Smith",
      "email": "x.coder.zach@gmail.com",
      "url": "https://github.com/xcoderzach"
    }
  ],
  "bugs": {
    "url": "http://github.com/tmpvar/jsdom/issues",
    "email": "tmpvar@gmail.com"
  },
  "license": {
    "type": "MIT",
    "url": "http://github.com/tmpvar/jsdom/blob/master/LICENSE.txt"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/tmpvar/jsdom.git"
  },
  "dependencies": {
    "htmlparser2": ">= 3.1.5 <4",
    "nwmatcher": "~1.3.2",
    "request": "2.x",
    "xmlhttprequest": ">=1.5.0",
    "cssom": "~0.3.0",
    "cssstyle": "~0.2.9",
    "contextify": "~0.1.5"
  },
  "devDependencies": {
    "nodeunit": "~0.8.0",
    "optimist": "*",
    "urlmaster": ">=0.2.15"
  },
  "scripts": {
    "test": "node ./test/runner"
  },
  "main": "./lib/jsdom",
  "readme": "# jsdom\n\nA JavaScript implementation of the WHATWG DOM and HTML standards.\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\nYou can use it with a URL\n\n```js\n// Count all of the links from the Node.js 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  url: \"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\", \"utf-8\");\n\njsdom.env({\n  url: \"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(string, [scripts], [config], callback);\n```\n\nThe arguments are:\n\n- `string`: may be a URL, file name, or HTML fragment\n- `scripts`: a string or array of strings, containing file names or URLs that will be inserted as `<script>` tags\n- `config`: see below\n- `callback`: takes two arguments\n  - `error`: either an `Error` object if something failed initializing the window, or an array of error messages from the DOM if there were script 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`: a HTML fragment\n- `config.file`: a file which jsdom will load HTML from; the resulting window's `location.href` will be a `file://` URL.\n- `config.url`: sets the resulting window's `location.href`; if `config.html` and `config.file` are not provided, jsdom will load HTML from this URL.\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.jar`: a custom cookie jar, if desired; see [mikeal/request](https://github.com/mikeal/request) documentation.\n- `config.done`: see `callback` above.\n- `config.document`:\n  - `referrer`: the new document will have this referrer.\n  - `cookie`: manually set a cookie value, e.g. `'key=value; expires=Wed, Sep 21 2011 12:00:00 GMT; path=/'`.\n  - `cookieDomain`: a cookie domain for the manually set cookie; defaults to `127.0.0.1`.\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\nNote that `config.done` is required, as is one of `config.html`, `config.file`, or `config.url`.\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.parentWindow;\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 explanation of the `config` object above.\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\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.parentWindow;\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().parentWindow;\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().parentWindow;\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## 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\n\nUnfortunately, getting C++ compiled within npm's installation system can be tricky, especially for Windows users. Thus,\none of the most common problems with jsdom is trying to use it without the proper compilation tools installed.\nHere's what you need to compile Contextify, and thus to install jsdom:\n\n### 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\n### Mac\n\n* XCode needs to be installed\n* \"Command line tools for XCode\" need to be installed\n* Launch XCode once to accept the license, etc. and ensure it's properly installed\n\n### Linux\n\nYou'll need various build tools installed, like `make`, Python 2.7, and a compiler toolchain. How to install these will\nbe specific to your distro, if you don't already have them.\n",
  "readmeFilename": "README.md",
  "homepage": "https://github.com/tmpvar/jsdom",
  "_id": "jsdom@0.11.1",
  "_from": "jsdom@0.11.1"
}
