Socket
Socket
Sign inDemoInstall

jsdom

Package Overview
Dependencies
1
Maintainers
1
Versions
259
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.12 to 0.1.13

8

lib/jsdom.js

@@ -9,5 +9,9 @@

exports.jsdom = function (level) {
exports.jsdom = function (html, level) {
level = level || exports.defaultLevel;
var doc = new (level.Document)();
var browser = exports.browserAugmentation(level);
doc = new (browser.Document)();
doc.innerHTML = html || "<html><head></head><body></body></html>";
doc.createWindow = function() {

@@ -14,0 +18,0 @@ var window = exports.windowAugmentation(level, { document: doc });

@@ -16,16 +16,22 @@ var sys = require('sys'),

var window = exports.createWindow(),
browser = browserAugmentation(dom, options),
head;
setupDoc = (typeof options.document === 'undefined');
options.document = (options.document) ?
options.document :
new (browser.Document)();
if (setupDoc) {
browser = browserAugmentation(dom, options),
options.document = new (browser.Document)();
}
window.document = options.document;
window.document.appendChild(window.document.createElement("html"));
head = window.document.createElement('head');
head.appendChild(window.document.createElement('title'));
window.document.documentElement.appendChild(head);
window.document.documentElement.appendChild(window.document.createElement('body'));
if (options.document.childNodes.length === 0) {
window.document.appendChild(window.document.createElement("html"));
var head = window.document.createElement('head');
head.appendChild(window.document.createElement('title'));
window.document.documentElement.appendChild(head);
window.document.documentElement.appendChild(
window.document.createElement('body')
);
}
window.document.addEventListener = function() {};

@@ -83,3 +89,5 @@ window.document.compareDocumentPosition = function() {};

window.navigator = {
userAgent: 'Node.js (' + process.platform + '; U; rv:' + process.version + ')',
userAgent: 'Node.js (' + process.platform + '; U; rv:' +
process.version + ')',
platform: process.platform,

@@ -232,3 +240,4 @@ appVersion: process.version

if (value.substring(0,7) === "file://") {
require("fs").readFile(value.replace("file://",""), function(err, data) {
require("fs").readFile(value.replace("file://",""), function(err, data)
{
if (err) throw err;

@@ -240,3 +249,6 @@ finish(data);

server = http.createClient(host.port || 80, host.hostname);
path = (host.search) ? host.pathname + "?" + host.search : host.pathname,
path = (host.search) ?
host.pathname + "?" + host.search :
host.pathname,
request = server.request('GET', path, {'host': host.hostname });

@@ -243,0 +255,0 @@ request.end();

{
"name": "jsdom",
"version": "0.1.12",
"version": "0.1.13",
"description": "CommonJS implementation of the DOM intended to be platform independent and as minimal/light as possible while completely adhering to the w3c DOM specifications.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -43,6 +43,4 @@ # jsdom

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

@@ -49,0 +47,0 @@ console.log(window.document.innerHTML);

@@ -7,4 +7,19 @@ var sys = require("sys");

assertNotNull("window must be a new object!", window);
assertNotNull(window.document);
},
jsdom_takes_html : function() {
var document = jsdom.jsdom('<a href="#test">');
assertEquals("Passing html into jsdom() should populate the resulting doc",
document.documentElement.getAttribute("href"),
"#test");
},
jsdom_method_creates_default_document : function() {
var doc = jsdom.jsdom();
assertEquals("Calling jsdom.jsdom() should automatically populate the doc",
doc.documentElement.nodeName,
"HTML");
},
jquerify : function() {

@@ -30,3 +45,4 @@ jsdom.jQueryify(jsdom.jsdom().createWindow(),

typeof window.document === 'undefined');
}
},
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc