Socket
Socket
Sign inDemoInstall

jsdom

Package Overview
Dependencies
149
Maintainers
6
Versions
258
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 16.5.1 to 16.5.2

lib/jsdom/living/helpers/iterable-weak-set.js

2

lib/api.js

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

// concurrentNodeIterators??
return transformed;

@@ -289,0 +287,0 @@ }

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

const { createElement } = require("../../living/helpers/create-element");
const { HTML_NS } = require("../../living/helpers/namespaces");

@@ -64,3 +65,3 @@ const DocumentType = require("../../living/generated/DocumentType");

if (_currentElement) {
return _currentElement.localName === "template" ?
return _currentElement.localName === "template" && _currentElement.namespaceURI === HTML_NS ?
_currentElement.content._ownerDocument :

@@ -200,3 +201,3 @@ _currentElement._ownerDocument;

function parseFragment(markup, contextElement) {
const ownerDocument = contextElement.localName === "template" ?
const ownerDocument = contextElement.localName === "template" && contextElement.namespaceURI === HTML_NS ?
contextElement.content._ownerDocument :

@@ -203,0 +204,0 @@ contextElement._ownerDocument;

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

referrer: options.referrer,
concurrentNodeIterators: options.concurrentNodeIterators,
parseOptions: options.parseOptions,

@@ -250,0 +249,0 @@ defaultView: this._globalProxy,

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

if (this._whenDefinedPromiseMap[name] !== undefined) {
this._whenDefinedPromiseMap[name].resolve(undefined);
this._whenDefinedPromiseMap[name].resolve(ctor);
delete this._whenDefinedPromiseMap[name];

@@ -232,5 +232,5 @@ }

const alreadyRegistered = this._customElementDefinitions.some(entry => entry.name === name);
const alreadyRegistered = this._customElementDefinitions.find(entry => entry.name === name);
if (alreadyRegistered) {
return Promise.resolve();
return Promise.resolve(alreadyRegistered.objectReference);
}

@@ -237,0 +237,0 @@

@@ -11,4 +11,17 @@ "use strict";

initMouseEvent(
type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY,
ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget
type,
bubbles,
cancelable,
view,
detail,
screenX,
screenY,
clientX,
clientY,
ctrlKey,
altKey,
shiftKey,
metaKey,
button,
relatedTarget
) {

@@ -15,0 +28,0 @@ if (this._dispatchFlag) {

@@ -118,42 +118,46 @@ "use strict";

if (event === "error" && element === null) {
const wrapperBody = document ? body + `\n//# sourceURL=${document.URL}` : body;
const sourceURL = document ? `\n//# sourceURL=${document.URL}` : "";
// eslint-disable-next-line no-new-func
fn = createFunction("window", `with (window) { return function onerror(event, source, lineno, colno, error) {
${wrapperBody}
}; }`)(window);
fn = createFunction(`\
with (arguments[0]) { return function onerror(event, source, lineno, colno, error) {
${body}
}; }${sourceURL}`)(window);
fn = OnErrorEventHandlerNonNull.convert(fn);
} else {
const argNames = [];
const args = [];
argNames.push("window");
args.push(window);
const calls = [];
if (element !== null) {
argNames.push("document");
args.push(idlUtils.wrapperForImpl(document));
calls.push(idlUtils.wrapperForImpl(document));
}
if (formOwner !== null) {
argNames.push("formOwner");
args.push(idlUtils.wrapperForImpl(formOwner));
calls.push(idlUtils.wrapperForImpl(formOwner));
}
if (element !== null) {
argNames.push("element");
args.push(idlUtils.wrapperForImpl(element));
calls.push(idlUtils.wrapperForImpl(element));
}
let wrapperBody = `
return function on${event}(event) {
${body}
};`;
for (let i = argNames.length - 1; i >= 0; --i) {
wrapperBody = `with (${argNames[i]}) { ${wrapperBody} }`;
let wrapperBody = `\
with (arguments[0]) { return function on${event}(event) {
${body}
}; }`;
// eslint-disable-next-line no-unused-vars
for (const call of calls) {
wrapperBody = `\
with (arguments[0]) { return function () {
${wrapperBody}
}; }`;
}
if (document) {
wrapperBody += `\n//# sourceURL=${document.URL}`;
}
argNames.push(wrapperBody);
fn = createFunction(...argNames)(...args);
fn = createFunction(wrapperBody)(window);
for (const call of calls) {
fn = fn(call);
}
if (event === "beforeunload") {

@@ -160,0 +164,0 @@ fn = OnBeforeUnloadEventHandlerNonNull.convert(fn);

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

exports.parseJSONFromBytes = bytes => {
// https://encoding.spec.whatwg.org/#utf-8-decode
if (bytes[0] === 0xEF && bytes[1] === 0xBB && bytes[2] === 0xBF) {
bytes = bytes.subarray(3);
}
const jsonText = bytes.toString("utf-8");

@@ -7,0 +11,0 @@

"use strict";
const CharacterDataImpl = require("./CharacterData-impl").implementation;
const idlUtils = require("../generated/utils");
const NODE_TYPE = require("../node-type");

@@ -11,2 +10,3 @@

data: args[0],
ownerDocument: idlUtils.implForWrapper(globalObject._document),
...privateData

@@ -13,0 +13,0 @@ });

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

const NODE_TYPE = require("../node-type");
const { mixin, memoizeQuery } = require("../../utils");
const { hasWeakRefs, mixin, memoizeQuery } = require("../../utils");
const { firstChildWithLocalName, firstChildWithLocalNames, firstDescendantWithLocalName } =

@@ -31,2 +31,3 @@ require("../helpers/traversal");

const { createElement, internalCreateElementNSSteps } = require("../helpers/create-element");
const IterableWeakSet = require("../helpers/iterable-weak-set");

@@ -147,3 +148,3 @@ const DocumentOrShadowRootImpl = require("./DocumentOrShadowRoot-impl").implementation;

this._cookieJar = privateData.options.cookieJar;
this._parseOptions = privateData.options.parseOptions;
this._parseOptions = privateData.options.parseOptions || {};
this._scriptingDisabled = privateData.options.scriptingDisabled;

@@ -154,2 +155,6 @@ if (this._cookieJar === undefined) {

if (this._scriptingDisabled) {
this._parseOptions.scriptingEnabled = false;
}
this.contentType = privateData.options.contentType;

@@ -176,15 +181,8 @@ this._encoding = privateData.options.encoding;

this._workingNodeIterators = [];
this._workingNodeIteratorsMax = privateData.options.concurrentNodeIterators === undefined ?
10 :
Number(privateData.options.concurrentNodeIterators);
if (isNaN(this._workingNodeIteratorsMax)) {
throw new TypeError("The 'concurrentNodeIterators' option must be a Number");
if (hasWeakRefs) {
this._workingNodeIterators = new IterableWeakSet();
} else {
this._workingNodeIterators = [];
}
if (this._workingNodeIteratorsMax < 0) {
throw new RangeError("The 'concurrentNodeIterators' option must be a non negative Number");
}
this._referrer = privateData.options.referrer || "";

@@ -786,6 +784,10 @@ this._lastModified = toLastModifiedString(privateData.options.lastModified || new Date());

this._workingNodeIterators.push(nodeIterator);
while (this._workingNodeIterators.length > this._workingNodeIteratorsMax) {
const toInactivate = this._workingNodeIterators.shift();
toInactivate._working = false;
if (hasWeakRefs) {
this._workingNodeIterators.add(nodeIterator);
} else {
this._workingNodeIterators.push(nodeIterator);
while (this._workingNodeIterators.length > 10) {
const toInactivate = this._workingNodeIterators.shift();
toInactivate._working = false;
}
}

@@ -792,0 +794,0 @@

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

const controls = [];
for (const el of domSymbolTree.treeIterator(this)) {
for (const el of this.elements) {
if (el.form === this && isSubmittable(el)) {

@@ -197,0 +197,0 @@ controls.push(el);

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

this._preCheckedRadioState = null;
this._legacyActivationBehaviorPreviousIndeterminateState = false;

@@ -171,2 +172,4 @@ this.indeterminate = false;

this.checked = !this.checked;
this._legacyActivationBehaviorPreviousIndeterminateState = this.indeterminate;
this.indeterminate = false;
} else if (this.type === "radio") {

@@ -181,2 +184,3 @@ this._preCheckedRadioState = this.checked;

this.checked = !this.checked;
this.indeterminate = this._legacyActivationBehaviorPreviousIndeterminateState;
} else if (this.type === "radio") {

@@ -198,4 +202,6 @@ if (this._preCheckedRadioState !== null) {

if (this.type === "checkbox" || (this.type === "radio" && !this._preCheckedRadioState)) {
fireAnEvent("input", this, undefined, { bubbles: true });
fireAnEvent("change", this, undefined, { bubbles: true });
if (this.isConnected) {
fireAnEvent("input", this, undefined, { bubbles: true });
fireAnEvent("change", this, undefined, { bubbles: true });
}
} else if (form && this.type === "submit") {

@@ -202,0 +208,0 @@ form._doSubmit();

"use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const { formOwner } = require("../helpers/form-controls");
const { HTML_NS } = require("../helpers/namespaces");
class HTMLLegendElementImpl extends HTMLElementImpl {
get form() {
return formOwner(this);
const parent = this.parentNode;
if (parent && parent._localName === "fieldset" && parent.namespaceURI === HTML_NS) {
return formOwner(parent);
}
return null;
}

@@ -9,0 +14,0 @@ }

"use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const NODE_TYPE = require("../node-type");
const { stripAndCollapseASCIIWhitespace } = require("../helpers/strings");
const { domSymbolTree } = require("../helpers/internal-constants");
const { HTML_NS, SVG_NS } = require("../helpers/namespaces");
const { closest } = require("../helpers/traversal");

@@ -70,4 +72,3 @@ const { formOwner } = require("../helpers/form-controls");

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

@@ -128,4 +129,20 @@ set text(value) {

function childTextContentExcludingDescendantsOfScript(root) {
let text = "";
for (const child of domSymbolTree.childrenIterator(root)) {
if (child._localName === "script" && (child._namespaceURI === HTML_NS || child._namespaceURI === SVG_NS)) {
continue;
}
if (child.nodeType === NODE_TYPE.TEXT_NODE || child.nodeType === NODE_TYPE.CDATA_SECTION_NODE) {
text += child.nodeValue;
} else {
text += childTextContentExcludingDescendantsOfScript(child);
}
}
return text;
}
module.exports = {
implementation: HTMLOptionElementImpl
};

@@ -14,4 +14,3 @@ "use strict";

this._labels = null;
this._defaultValue = "";
this._valueMode = "default";
this._defaultValueOverride = null;

@@ -34,8 +33,4 @@ this._customValidityErrorMessage = "";

_formReset() {
if (this._valueMode === "value") {
this.textContent = this._defaultValue;
}
this._defaultValue = "";
this._valueMode = "default";
this.textContent = this.defaultValue;
this._defaultValueOverride = null;
}

@@ -70,4 +65,3 @@

set value(val) {
this._valueMode = "value";
this._defaultValue = this.textContent;
this._defaultValueOverride = this.defaultValue;
this.textContent = val;

@@ -77,11 +71,15 @@ }

get defaultValue() {
return this._valueMode === "default" ? this.textContent : this._defaultValue;
if (this._defaultValueOverride !== null) {
return this._defaultValueOverride;
}
return this.textContent;
}
set defaultValue(val) {
this._defaultValue = val;
if (this._valueMode === "default") {
if (this._defaultValueOverride === null) {
this.textContent = val;
return;
}
this._defaultValueOverride = val;
}

@@ -88,0 +86,0 @@ }

"use strict";
const SlotableMixinImpl = require("./Slotable-impl").implementation;
const CharacterDataImpl = require("./CharacterData-impl").implementation;
const idlUtils = require("../generated/utils");
const { domSymbolTree } = require("../helpers/internal-constants");

@@ -16,2 +15,3 @@ const DOMException = require("domexception/webidl2js-wrapper");

data: args[0],
ownerDocument: idlUtils.implForWrapper(globalObject._document),
...privateData

@@ -18,0 +18,0 @@ });

"use strict";
const { hasWeakRefs } = require("../../utils");
const { domSymbolTree } = require("../helpers/internal-constants");

@@ -15,7 +16,8 @@ const { filter, FILTER_ACCEPT } = require("./helpers");

// This is used to deactive the NodeIterator if there are too many working in a Document at the same time.
// This is used to deactivate the NodeIterator if there are too many working in a Document at the same time.
// Without weak references, a JS implementation of NodeIterator will leak, since we can't know when to clean it up.
// This ensures we force a clean up of those beyond some maximum (specified by the Document).
this._working = true;
this._workingNodeIteratorsMax = privateData.workingNodeIteratorsMax;
if (!hasWeakRefs) {
this._working = true;
}

@@ -83,5 +85,5 @@ this._globalObject = globalObject;

_throwIfNotWorking() {
if (!this._working) {
throw Error(`This NodeIterator is no longer working. More than ${this._workingNodeIteratorsMax} iterators are ` +
`being used concurrently. You can increase the 'concurrentNodeIterators' option to make this error go away.`);
if (!hasWeakRefs && !this._working) {
throw Error(`This NodeIterator is no longer working. More than 10 iterators are being used concurrently. ` +
`Using more than 10 node iterators requires WeakRef support.`);
}

@@ -88,0 +90,0 @@ }

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

const acah = new Set(acahStr ? acahStr.trim().toLowerCase().split(headerListSeparatorRegexp) : []);
const forbiddenHeaders = Object.keys(flag.requestHeaders).filter(header => {
const forbiddenHeaders = acah.has("*") ?
[] :
Object.keys(flag.requestHeaders).filter(header => {
const lcHeader = header.toLowerCase();

@@ -96,0 +98,0 @@ return !simpleHeaders.has(lcHeader) && !acah.has(lcHeader);

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

exports.hasWeakRefs = typeof WeakRef === "function";
exports.toFileUrl = function (fileName) {

@@ -9,0 +11,0 @@ // Beyond just the `path.resolve`, this is mostly for the benefit of Windows,

{
"name": "jsdom",
"version": "16.5.1",
"version": "16.5.2",
"description": "A JavaScript implementation of many web standards",

@@ -24,3 +24,3 @@ "keywords": [

"abab": "^2.0.5",
"acorn": "^8.0.5",
"acorn": "^8.1.0",
"acorn-globals": "^6.0.0",

@@ -47,3 +47,3 @@ "cssom": "^0.4.4",

"whatwg-mimetype": "^2.3.0",
"whatwg-url": "^8.0.0",
"whatwg-url": "^8.5.0",
"ws": "^7.4.4",

@@ -64,11 +64,11 @@ "xml-name-validator": "^3.0.0"

"devDependencies": {
"@domenic/eslint-config": "^1.0.0",
"@domenic/eslint-config": "^1.1.0",
"benchmark": "^2.1.4",
"browserify": "^17.0.0",
"chai": "^4.3.3",
"eslint": "^7.21.0",
"eslint-plugin-html": "^6.1.1",
"chai": "^4.3.4",
"eslint": "^7.23.0",
"eslint-plugin-html": "^6.1.2",
"eslint-plugin-jsdom-internal": "link:./scripts/eslint-plugin",
"js-yaml": "^4.0.0",
"karma": "^6.1.1",
"karma": "^6.3.1",
"karma-browserify": "^8.0.0",

@@ -79,3 +79,3 @@ "karma-chrome-launcher": "^3.1.0",

"minimatch": "^3.0.4",
"mocha": "^8.3.1",
"mocha": "^8.3.2",
"mocha-sugar-free": "^1.4.0",

@@ -82,0 +82,0 @@ "optimist": "0.6.1",

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc