Socket
Socket
Sign inDemoInstall

jsdom

Package Overview
Dependencies
105
Maintainers
6
Versions
258
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 23.1.0 to 23.2.0

60

lib/jsdom/living/helpers/selectors.js
"use strict";
const nwsapi = require("nwsapi");
const domSelector = require("@asamuzakjp/dom-selector");
const { wrapperForImpl } = require("../generated/utils");
const idlUtils = require("../generated/utils");
function initNwsapi(node) {
const { _globalObject, _ownerDocument } = node;
return nwsapi({
document: idlUtils.wrapperForImpl(_ownerDocument),
DOMException: _globalObject.DOMException
});
}
exports.matchesDontThrow = (elImpl, selector) => {
const document = elImpl._ownerDocument;
if (!document._nwsapiDontThrow) {
document._nwsapiDontThrow = initNwsapi(elImpl);
document._nwsapiDontThrow.configure({
LOGERRORS: false,
VERBOSITY: false,
IDS_DUPES: true,
MIXEDCASE: true
});
exports.matchesDontThrow = (selectors, elementImpl) => {
const element = wrapperForImpl(elementImpl);
try {
return domSelector.matches(selectors, element);
} catch {
return false;
}
};
return document._nwsapiDontThrow.match(selector, idlUtils.wrapperForImpl(elImpl));
exports.matches = (selectors, elementImpl) => {
const element = wrapperForImpl(elementImpl);
return domSelector.matches(selectors, element);
};
// nwsapi gets `document.documentElement` at creation-time, so we have to initialize lazily, since in the initial
// stages of Document initialization, there is no documentElement present yet.
exports.addNwsapi = parentNode => {
const document = parentNode._ownerDocument;
exports.closest = (selectors, elementImpl) => {
const element = wrapperForImpl(elementImpl);
return domSelector.closest(selectors, element);
};
if (!document._nwsapi) {
document._nwsapi = initNwsapi(parentNode);
document._nwsapi.configure({
LOGERRORS: false,
IDS_DUPES: true,
MIXEDCASE: true
});
}
exports.querySelector = (selectors, parentNodeImpl) => {
const node = wrapperForImpl(parentNodeImpl);
return domSelector.querySelector(selectors, node);
};
return document._nwsapi;
exports.querySelectorAll = (selectors, parentNodeImpl) => {
const node = wrapperForImpl(parentNodeImpl);
return domSelector.querySelectorAll(selectors, node);
};
"use strict";
const cssom = require("rrweb-cssom");

@@ -171,4 +172,4 @@ const { CSSStyleDeclaration } = require("cssstyle");

function matches(rule, element) {
return matchesDontThrow(element, rule.selectorText);
function matches(rule, elementImpl) {
return matchesDontThrow(rule.selectorText, elementImpl);
}

@@ -175,0 +176,0 @@

"use strict";
const { addNwsapi } = require("../helpers/selectors");
const { closest, matches } = require("../helpers/selectors");
const { HTML_NS } = require("../helpers/namespaces");
const { mixin, memoizeQuery } = require("../../utils");
const idlUtils = require("../generated/utils");
const NodeImpl = require("./Node-impl").implementation;

@@ -549,6 +548,13 @@ const ParentNodeImpl = require("./ParentNode-impl").implementation;

closest(selectors) {
const matcher = addNwsapi(this);
return matcher.closest(selectors, idlUtils.wrapperForImpl(this));
return closest(selectors, this);
}
matches(selectors) {
return matches(selectors, this);
}
webkitMatchesSelector(selectors) {
return matches(selectors, this);
}
// https://html.spec.whatwg.org/#reflecting-content-attributes-in-idl-attributes

@@ -590,12 +596,4 @@ _reflectGetTheElement() {

ElementImpl.prototype.matches = function (selectors) {
const matcher = addNwsapi(this);
return matcher.match(selectors, idlUtils.wrapperForImpl(this));
};
ElementImpl.prototype.webkitMatchesSelector = ElementImpl.prototype.matches;
module.exports = {
implementation: ElementImpl
};
"use strict";
const idlUtils = require("../generated/utils");
const NodeList = require("../generated/NodeList");
const HTMLCollection = require("../generated/HTMLCollection");
const { addNwsapi } = require("../helpers/selectors");
const { querySelector, querySelectorAll } = require("../helpers/selectors");
const { domSymbolTree } = require("../helpers/internal-constants");

@@ -65,7 +64,3 @@ const NODE_TYPE = require("../node-type");

querySelector(selectors) {
if (shouldAlwaysSelectNothing(this)) {
return null;
}
const matcher = addNwsapi(this);
return idlUtils.implForWrapper(matcher.first(selectors, idlUtils.wrapperForImpl(this)));
return querySelector(selectors, this);
}

@@ -75,19 +70,9 @@

querySelectorAll(selectors) {
if (shouldAlwaysSelectNothing(this)) {
return NodeList.create(this._globalObject, [], { nodes: [] });
}
const matcher = addNwsapi(this);
const list = matcher.select(selectors, idlUtils.wrapperForImpl(this));
return NodeList.create(this._globalObject, [], { nodes: list.map(n => idlUtils.tryImplForWrapper(n)) });
const nodes = querySelectorAll(selectors, this);
return NodeList.create(this._globalObject, [], { nodes });
}
}
function shouldAlwaysSelectNothing(elImpl) {
// This is true during initialization.
return elImpl === elImpl._ownerDocument && !elImpl.documentElement;
}
module.exports = {
implementation: ParentNodeImpl
};
{
"name": "jsdom",
"version": "23.1.0",
"version": "23.2.0",
"description": "A JavaScript implementation of many web standards",

@@ -23,2 +23,3 @@ "keywords": [

"dependencies": {
"@asamuzakjp/dom-selector": "^2.0.1",
"cssstyle": "^4.0.1",

@@ -32,3 +33,2 @@ "data-urls": "^5.0.0",

"is-potential-custom-element-name": "^1.0.1",
"nwsapi": "^2.2.7",
"parse5": "^7.1.2",

@@ -35,0 +35,0 @@ "rrweb-cssom": "^0.6.0",

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