Socket
Socket
Sign inDemoInstall

jsdom

Package Overview
Dependencies
Maintainers
3
Versions
264
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdom - npm Package Compare versions

Comparing version 9.11.0 to 9.12.0

lib/jsdom/living/helpers/strings.js

5

lib/jsdom.js

@@ -255,2 +255,4 @@ "use strict";

const fragment = whatwgURL.parseURL(config.url).fragment;
return resourceLoader.download(config.url, options, (err, responseText, res) => {

@@ -266,2 +268,5 @@ if (err) {

config.url = res.request.uri.href;
if (fragment) {
config.url += `#${fragment}`;
}

@@ -268,0 +273,0 @@ if (res.headers["last-modified"]) {

53

lib/jsdom/browser/Window.js
"use strict";
const webIDLConversions = require("webidl-conversions");
const CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;

@@ -174,3 +175,3 @@ const notImplemented = require("./not-implemented");

}
return startTimer(window, setTimeout, clearTimeout, latestTimerId++, fn, ms, args);
return startTimer(window, setTimeout, clearTimeout, ++latestTimerId, fn, ms, args);
};

@@ -182,3 +183,3 @@ this.setInterval = function (fn, ms) {

}
return startTimer(window, setInterval, clearInterval, latestTimerId++, fn, ms, args);
return startTimer(window, setInterval, clearInterval, ++latestTimerId, fn, ms, args);
};

@@ -189,2 +190,44 @@ this.clearInterval = stopTimer.bind(this, window);

function Option(text, value, defaultSelected, selected) {
if (text === undefined) {
text = "";
}
text = webIDLConversions.DOMString(text);
if (value !== undefined) {
value = webIDLConversions.DOMString(value);
}
defaultSelected = webIDLConversions.boolean(defaultSelected);
selected = webIDLConversions.boolean(selected);
const option = window._document.createElement("option");
const impl = idlUtils.implForWrapper(option);
if (text !== "") {
impl.text = text;
}
if (value !== undefined) {
impl.setAttribute("value", value);
}
if (defaultSelected) {
impl.setAttribute("selected", "");
}
impl._selectedness = selected;
return option;
}
Object.defineProperty(Option, "prototype", {
value: this.HTMLOptionElement.prototype,
configurable: false,
enumerable: false,
writable: false
});
Object.defineProperty(window, "Option", {
value: Option,
configurable: true,
enumerable: false,
writable: true
});
function Image() {

@@ -497,3 +540,4 @@ const img = window._document.createElement("img");

if (timer) {
timer[1].call(window, timer[0]);
// Need to .call() with undefined to ensure the thisArg is not timer itself
timer[1].call(undefined, timer[0]);
delete window.__timers[id];

@@ -506,5 +550,6 @@ }

const timer = window.__timers[key];
timer[1].call(window, timer[0]);
// Need to .call() with undefined to ensure the thisArg is not timer itself
timer[1].call(undefined, timer[0]);
});
window.__timers = Object.create(null);
}

2

lib/jsdom/living/events/Event-impl.js

@@ -53,3 +53,3 @@ "use strict";

this._stopPropagationFlag = true;
this._stopImmediatePropagation = true;
this._stopImmediatePropagationFlag = true;
}

@@ -56,0 +56,0 @@

@@ -43,2 +43,3 @@ "use strict";

args[2] = conversions["boolean"](args[2]);
args[3] = conversions["any"](args[3]);
return this[impl].initCustomEvent.apply(this[impl], args);

@@ -55,3 +56,3 @@ };

get() {
return utils.tryWrapperForImpl(this[impl].detail);
return this[impl].detail;
},

@@ -58,0 +59,0 @@ enumerable: true,

@@ -16,3 +16,3 @@ "use strict";

if (value !== undefined) {
ret[key] = (value);
ret[key] = conversions["any"](value);
} else {

@@ -19,0 +19,0 @@ ret[key] = null;

@@ -69,3 +69,3 @@ "use strict";

get() {
return utils.tryWrapperForImpl(this[impl].error);
return this[impl].error;
},

@@ -72,0 +72,0 @@ enumerable: true,

@@ -22,3 +22,3 @@ "use strict";

if (value !== undefined) {
ret[key] = (value);
ret[key] = conversions["any"](value);
}

@@ -25,0 +25,0 @@

@@ -188,3 +188,3 @@ "use strict";

get() {
return utils.tryWrapperForImpl(this[impl].timeStamp);
return this[impl].timeStamp;
},

@@ -191,0 +191,0 @@ enumerable: true,

@@ -61,2 +61,3 @@ "use strict";

}
args[0] = conversions["any"](args[0]);
args[1] = conversions["DOMString"](args[1]);

@@ -86,2 +87,3 @@ if (args[2] === null || args[2] === undefined) {

}
args[0] = conversions["any"](args[0]);
args[1] = conversions["DOMString"](args[1]);

@@ -116,3 +118,3 @@ if (args[2] === null || args[2] === undefined) {

get() {
return utils.tryWrapperForImpl(this[impl].state);
return this[impl].state;
},

@@ -119,0 +121,0 @@ enumerable: true,

@@ -27,2 +27,5 @@ "use strict";

args[0] = conversions["DOMString"](args[0]);
if (args[1] !== undefined) {
args[1] = conversions["any"](args[1]);
}
return utils.tryWrapperForImpl(this[impl].getContext.apply(this[impl], args));

@@ -43,2 +46,5 @@ };

args[0] = conversions["DOMString"](args[0]);
if (args[1] !== undefined) {
args[1] = conversions["any"](args[1]);
}
return this[impl].probablySupportsContext.apply(this[impl], args);

@@ -72,2 +78,5 @@ };

}
if (args[1] !== undefined) {
args[1] = conversions["any"](args[1]);
}
return this[impl].toDataURL.apply(this[impl], args);

@@ -90,2 +99,5 @@ };

}
if (args[2] !== undefined) {
args[2] = conversions["any"](args[2]);
}
return this[impl].toBlob.apply(this[impl], args);

@@ -92,0 +104,0 @@ };

@@ -43,2 +43,3 @@ "use strict";

args[2] = conversions["boolean"](args[2]);
args[3] = conversions["any"](args[3]);
args[4] = conversions["DOMString"](args[4]);

@@ -65,3 +66,3 @@ args[5] = conversions["DOMString"](args[5]);

get() {
return utils.tryWrapperForImpl(this[impl].data);
return this[impl].data;
},

@@ -68,0 +69,0 @@ enumerable: true,

@@ -16,3 +16,3 @@ "use strict";

if (value !== undefined) {
ret[key] = (value);
ret[key] = conversions["any"](value);
}

@@ -19,0 +19,0 @@

@@ -37,3 +37,3 @@ "use strict";

get() {
return utils.tryWrapperForImpl(this[impl].state);
return this[impl].state;
},

@@ -40,0 +40,0 @@ enumerable: true,

@@ -16,3 +16,3 @@ "use strict";

if (value !== undefined) {
ret[key] = (value);
ret[key] = conversions["any"](value);
}

@@ -19,0 +19,0 @@ },

@@ -15,2 +15,3 @@ "use strict";

const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const stripAndCollapseASCIIWhitespace = require("../helpers/strings").stripAndCollapseASCIIWhitespace;
const DOMException = require("../../web-idl/DOMException");

@@ -546,3 +547,3 @@ const HtmlToDom = require("../../browser/htmltodom").HtmlToDom;

let value = titleElement !== null ? titleElement.textContent : "";
value = value.replace(/[ \t\n\f\r]+/g, " ").replace(/^[ \t\n\f\r]+/, "").replace(/[ \t\n\f\r]+$/, "");
value = stripAndCollapseASCIIWhitespace(value);
return value;

@@ -549,0 +550,0 @@ }

"use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const defineGetter = require("../../utils").defineGetter;
const defineSetter = require("../../utils").defineSetter;
const proxiedWindowEventHandlers = require("../helpers/proxied-window-event-handlers");
class HTMLBodyElementImpl extends HTMLElementImpl {
class HTMLBodyElementImpl extends HTMLElementImpl {}
}
(function () {
proxiedWindowEventHandlers.forEach(name => {
defineSetter(HTMLBodyElementImpl.prototype, name, function (handler) {
for (const name of proxiedWindowEventHandlers) {
Object.defineProperty(HTMLBodyElementImpl.prototype, name, {
configurable: true,
enumerable: true,
get() {
const window = this._ownerDocument._defaultView;
return window ? window[name] : null;
},
set(handler) {
const window = this._ownerDocument._defaultView;
if (window) {
window[name] = handler;
}
});
defineGetter(HTMLBodyElementImpl.prototype, name, function () {
const window = this._ownerDocument._defaultView;
return window ? window[name] : null;
});
}
});
}());
}

@@ -28,0 +24,0 @@ module.exports = {

@@ -5,3 +5,3 @@ "use strict";

const idlUtils = require("../generated/utils");
const stripAndCollapseASCIIWhitespace = require("../helpers/strings").stripAndCollapseASCIIWhitespace;
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;

@@ -68,4 +68,4 @@ const closest = require("../helpers/traversal").closest;

get text() {
// TODO this is wrong
return this.innerHTML;
// TODO is not correctly excluding script and SVG script descendants
return stripAndCollapseASCIIWhitespace(this.textContent);
}

@@ -77,4 +77,3 @@ set text(V) {

get value() {
// TODO fallback is wrong
return this.hasAttribute("value") ? this.getAttribute("value") : this.innerHTML;
return this.hasAttribute("value") ? this.getAttribute("value") : this.text;
}

@@ -81,0 +80,0 @@ set value(val) {

@@ -23,22 +23,2 @@ "use strict";

/**
* Define a setter on an object
*
* This method replaces any existing setter but leaves getters in place.
*
* - `object` {Object} the object to define the setter on
* - `property` {String} the name of the setter
* - `setterFn` {Function} the setter
*/
exports.defineSetter = function defineSetter(object, property, setterFn) {
const descriptor = Object.getOwnPropertyDescriptor(object, property) || {
configurable: true,
enumerable: true
};
descriptor.set = setterFn;
Object.defineProperty(object, property, descriptor);
};
/**
* Define a getter on an object

@@ -235,10 +215,13 @@ *

exports.Canvas = null;
try {
exports.Canvas = require("canvas");
if (typeof exports.Canvas !== "function") {
// In browserify, the require will succeed but return an empty object
["canvas", "canvas-prebuilt"].some(moduleName => {
try {
exports.Canvas = require(moduleName);
if (typeof exports.Canvas !== "function") {
// In browserify, the require will succeed but return an empty object
exports.Canvas = null;
}
} catch (e) {
exports.Canvas = null;
}
} catch (e) {
exports.Canvas = null;
}
return exports.Canvas !== null;
});
{
"name": "jsdom",
"version": "9.11.0",
"version": "9.12.0",
"description": "A JavaScript implementation of the DOM and HTML standards",

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

@@ -382,3 +382,3 @@ # jsdom

jsdom 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.
jsdom includes support for using the [canvas](https://npmjs.org/package/canvas) or [canvas-prebuilt](https://npmjs.org/package/canvas-prebuilt) 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.

@@ -385,0 +385,0 @@ ## More Examples

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc