8000 GitHub - gavinuhma/jsdom at swizec-merge · GitHub
[go: up one dir, main page]

Skip to content
{"props":{"color_mode":"dark","logged_in":false,"marketing_page":false,"home_path":"/","login_path":"/login?return_to=https%3A%2F%2FgitHub.com%2Fgavinuhma%2Fjsdom%2Ftree%2Fswizec-merge","signup_path":"/signup?ref_cta=Sign+up\u0026ref_loc=header+logged+out\u0026ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Ffiles%2Fdisambiguate\u0026source=header-repo\u0026source_repo=gavinuhma%2Fjsdom","signup_enabled":true,"is_signup_controller":false,"show_search_and_nav":true,"hide_search":false,"private_mode_enabled":false,"should_use_dotcom_links":true,"auth_hydro_click":"{\"event_type\":\"authentication.click\",\"payload\":{\"location_in_page\":\"site header menu\",\"repository_id\":null,\"auth_type\":\"SIGN_UP\",\"originating_url\":\"https://gitHub.com/gavinuhma/jsdom/tree/swizec-merge\",\"user_id\":null}}","auth_hydro_click_hmac":"fcca5c568b36af668dc6bcb3a769115dd391cb77b354d67ad2874d677885ac15"}}
gavinuhmaPublic
forked from jsdom/jsdom

About

CommonJS implementation of the DOM intended to be platform independent and as minimal/light as possible while completely adhering to the w3c DOM specifications.

Resources

Stars

1 star

Watchers

1 watching

Forks

 
 

Latest commit

 

History

405 Commits

Folders and files

Repository files navigation

jsdom

CommonJS implementation of the DOM intended to be platform independent and as minimal/light as possible while completely adhering to the w3c DOM specifications.

Currently Implemented and w3c Compliant:

  • DOM Level 1 (html/svg/xml)
  • Browser (BOM) Augmentation (getElementsByClassName, getElementById, etc..)

Note: Running the tests now requires mjsunit.runner

see: testlog for w3 test compliance

see: plan for roadmap and thoughts about this project

see: project site for additional information

Examples

Creating a document-less window

var jsdom  = require("jsdom"),
    window = jsdom.createWindow();

console.log(window.document);
// output: undefined

Creating a document

var jsdom = require("jsdom"),
    doc   = new (jsdom.dom.level1.core.Document)();
console.log(doc.nodeName);
// outputs: #document

Creating a browser-like BOM/DOM/Window

var jsdom  = require("./lib/jsdom").jsdom,
    window = jsdom("<html><head></head><body>hello world</body></html>").createWindow();

console.log(window.document.innerHTML);
// output: '<html><head></head><body>hello world</body></html>'

console.log(window.innerWidth)
// output: 1024

console.log(typeof window.document.getElementsByClassName);
// outputs: function

Load arbitrary scripts

var jsdom  = require("jsdom").jsdom,
    window = jsdom().createWindow(),
    script = window.document.createElement("script");

script.src = 'http://code.jquery.com/jquery-1.4.2.js';

script. {
  if (this.readyState === 'complete') {
    console.log(window.jQuery.fn.jquery);
    // outputs: 1.4.2
  }
};

jQueryify

var jsdom  = require("jsdom"),
    window = jsdom.jsdom().createWindow();

jsdom.jQueryify(window, "http://code.jquery.com/jquery-1.4.2.min.js" , function() {
  window.jQuery('body').append(<div class='testing'>Hello World, It works</div>");
  console.log(window.jQuery(".testing").text());
});

About

CommonJS implementation of the DOM intended to be platform independent and as minimal/light as possible while completely adhering to the w3c DOM specifications.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0