Socket
Socket
Sign inDemoInstall

jsdom

Package Overview
Dependencies
91
Maintainers
3
Versions
259
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 11.8.0 to 11.9.0

8

lib/jsdom/living/attributes.js

@@ -215,2 +215,10 @@ "use strict";

exports.setAnExistingAttributeValue = (attribute, value) => {
if (attribute._element === null) {
attribute._value = value;
}
exports.changeAttribute(attribute._element, attribute, value);
};
exports.removeAttributeByName = function (element, name) {

@@ -217,0 +225,0 @@ // https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name

77

lib/jsdom/living/generated/Node.js

@@ -148,2 +148,79 @@ "use strict";

Node.prototype.lookupPrefix = function lookupPrefix(namespace) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'lookupPrefix' on 'Node': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'lookupPrefix' on 'Node': parameter 1" });
}
args.push(curArg);
}
return this[impl].lookupPrefix(...args);
};
Node.prototype.lookupNamespaceURI = function lookupNamespaceURI(prefix) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'lookupNamespaceURI' on 'Node': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'lookupNamespaceURI' on 'Node': parameter 1"
});
}
args.push(curArg);
}
return this[impl].lookupNamespaceURI(...args);
};
Node.prototype.isDefaultNamespace = function isDefaultNamespace(namespace) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'isDefaultNamespace' on 'Node': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'isDefaultNamespace' on 'Node': parameter 1"
});
}
args.push(curArg);
}
return this[impl].isDefaultNamespace(...args);
};
Node.prototype.insertBefore = function insertBefore(node, child) {

@@ -150,0 +227,0 @@ if (!this || !module.exports.is(this)) {

@@ -17,10 +17,9 @@ "use strict";

case NODE_TYPE.DOCUMENT_NODE:
// TODO: just use Document when we eliminate the difference between Document and HTMLDocument.
if (node.contentType === "text/html") { // need to differentiate due to parsing mode
copy = document.implementation.createHTMLDocument();
copy.removeChild(copy.documentElement); // ;_;
} else {
copy = document.implementation.createDocument("", "", null);
}
document = copy;
// Can't use a simple Document.createImpl because of circular dependency issues :-/
copy = document.implementation.createDocument(null, "", null);
copy._encoding = node._encoding;
copy._contentType = node._contentType;
copy._URL = node._URL;
copy._origin = node._origin;
copy._parsingMode = node._parsingMode;
break;

@@ -234,1 +233,84 @@

};
// https://dom.spec.whatwg.org/#locate-a-namespace-prefix
exports.locateNamespacePrefix = (element, namespace) => {
if (element._namespaceURI === namespace && element._prefix !== null) {
return element._prefix;
}
for (const attribute of element._attributeList) {
if (attribute._namespacePrefix === "xmlns" && attribute._value === namespace) {
return attribute._localName;
}
}
if (element.parentElement !== null) {
return exports.locateNamespacePrefix(element.parentElement, namespace);
}
return null;
};
// https://dom.spec.whatwg.org/#locate-a-namespace
exports.locateNamespace = (node, prefix) => {
switch (node.nodeType) {
case NODE_TYPE.ELEMENT_NODE: {
if (node._namespaceURI !== null && node._prefix === prefix) {
return node._namespaceURI;
}
if (prefix === null) {
for (const attribute of node._attributeList) {
if (attribute._namespace === "http://www.w3.org/2000/xmlns/" &&
attribute._namespacePrefix === null &&
attribute._localName === "xmlns") {
return attribute._value !== "" ? attribute._value : null;
}
}
} else {
for (const attribute of node._attributeList) {
if (attribute._namespace === "http://www.w3.org/2000/xmlns/" &&
attribute._namespacePrefix === "xmlns" &&
attribute._localName === prefix) {
return attribute._value !== "" ? attribute._value : null;
}
}
}
if (node.parentElement === null) {
return null;
}
return exports.locateNamespace(node.parentElement, prefix);
}
case NODE_TYPE.DOCUMENT_NODE: {
if (node.documentElement === null) {
return null;
}
return exports.locateNamespace(node.documentElement, prefix);
}
case NODE_TYPE.DOCUMENT_TYPE_NODE:
case NODE_TYPE.DOCUMENT_FRAGMENT_NODE: {
return null;
}
case NODE_TYPE.ATTRIBUTE_NODE: {
if (node._element === null) {
return null;
}
return exports.locateNamespace(node._element, prefix);
}
default: {
if (node.parentElement === null) {
return null;
}
return exports.locateNamespace(node.parentElement, prefix);
}
}
};

6

lib/jsdom/living/nodes/DOMImplementation-impl.js

@@ -29,8 +29,2 @@ "use strict";

createDocument(namespace, qualifiedName, doctype) {
namespace = namespace !== null ? String(namespace) : namespace;
qualifiedName = qualifiedName === null ? "" : String(qualifiedName);
if (doctype === undefined) {
doctype = null;
}
const document = Document.createImpl([], {

@@ -37,0 +31,0 @@ options: { parsingMode: "xml", encoding: "UTF-8" }

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

stream = canvas.createJPEGStream({
quality: Math.min(0, Math.max(1, qualityArgument)) * 100
quality: Math.max(0, Math.min(1, qualityArgument)) * 100
});

@@ -74,0 +74,0 @@ break;

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

const { documentBaseURLSerialized } = require("../helpers/document-base-url");
const cloneNode = require("../node").clone;
const { clone, locateNamespacePrefix, locateNamespace } = require("../node");
const attributes = require("../attributes");

@@ -86,22 +86,2 @@

get nodeValue() {
if (this.nodeType === NODE_TYPE.TEXT_NODE ||
this.nodeType === NODE_TYPE.COMMENT_NODE ||
this.nodeType === NODE_TYPE.CDATA_SECTION_NODE ||
this.nodeType === NODE_TYPE.PROCESSING_INSTRUCTION_NODE) {
return this._data;
}
return null;
}
set nodeValue(value) {
if (this.nodeType === NODE_TYPE.TEXT_NODE ||
this.nodeType === NODE_TYPE.COMMENT_NODE ||
this.nodeType === NODE_TYPE.CDATA_SECTION_NODE ||
this.nodeType === NODE_TYPE.PROCESSING_INSTRUCTION_NODE) {
this.replaceData(0, this.length, value);
}
}
get parentNode() {

@@ -389,2 +369,44 @@ return domSymbolTree.parent(this);

lookupPrefix(namespace) {
if (namespace === null || namespace === "") {
return null;
}
switch (this.nodeType) {
case NODE_TYPE.ELEMENT_NODE: {
return locateNamespacePrefix(this, namespace);
}
case NODE_TYPE.DOCUMENT_NODE: {
return this.documentElement !== null ? locateNamespacePrefix(this.documentElement, namespace) : null;
}
case NODE_TYPE.DOCUMENT_TYPE_NODE:
case NODE_TYPE.DOCUMENT_FRAGMENT_NODE: {
return null;
}
case NODE_TYPE.ATTRIBUTE_NODE: {
return this._element !== null ? locateNamespacePrefix(this._element, namespace) : null;
}
default: {
return this.parentElement !== null ? locateNamespacePrefix(this.parentElement, namespace) : null;
}
}
}
lookupNamespaceURI(prefix) {
if (prefix === "") {
prefix = null;
}
return locateNamespace(this, prefix);
}
isDefaultNamespace(namespace) {
if (namespace === "") {
namespace = null;
}
const defaultNamespace = locateNamespace(this, null);
return defaultNamespace === namespace;
}
contains(other) {

@@ -423,18 +445,47 @@ if (other === null) {

return cloneNode(this, undefined, deep);
return clone(this, undefined, deep);
}
get textContent() {
let text;
get nodeValue() {
switch (this.nodeType) {
case NODE_TYPE.COMMENT_NODE:
case NODE_TYPE.CDATA_SECTION_NODE:
case NODE_TYPE.ATTRIBUTE_NODE: {
return this._value;
}
case NODE_TYPE.TEXT_NODE:
case NODE_TYPE.CDATA_SECTION_NODE: // CDATASection is a subclass of Text
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
case NODE_TYPE.COMMENT_NODE: {
return this._data;
}
default: {
return null;
}
}
}
set nodeValue(value) {
if (value === null) {
value = "";
}
switch (this.nodeType) {
case NODE_TYPE.ATTRIBUTE_NODE: {
attributes.setAnExistingAttributeValue(this, value);
break;
}
case NODE_TYPE.TEXT_NODE:
return this.nodeValue;
case NODE_TYPE.CDATA_SECTION_NODE: // CDATASection is a subclass of Text
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
case NODE_TYPE.COMMENT_NODE: {
this.replaceData(0, this.length, value);
break;
}
}
}
case NODE_TYPE.ATTRIBUTE_NODE:
get textContent() {
switch (this.nodeType) {
case NODE_TYPE.DOCUMENT_FRAGMENT_NODE:
case NODE_TYPE.ELEMENT_NODE:
text = "";
case NODE_TYPE.ELEMENT_NODE: {
let text = "";
for (const child of domSymbolTree.treeIterator(this)) {

@@ -446,26 +497,50 @@ if (child.nodeType === NODE_TYPE.TEXT_NODE || child.nodeType === NODE_TYPE.CDATA_SECTION_NODE) {

return text;
}
default:
case NODE_TYPE.ATTRIBUTE_NODE: {
return this._value;
}
case NODE_TYPE.TEXT_NODE:
case NODE_TYPE.CDATA_SECTION_NODE: // CDATASection is a subclass of Text
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
case NODE_TYPE.COMMENT_NODE: {
return this._data;
}
default: {
return null;
}
}
}
set textContent(txt) {
set textContent(value) {
switch (this.nodeType) {
case NODE_TYPE.COMMENT_NODE:
case NODE_TYPE.CDATA_SECTION_NODE:
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
case NODE_TYPE.TEXT_NODE:
this.nodeValue = String(txt);
return;
}
case NODE_TYPE.DOCUMENT_FRAGMENT_NODE:
case NODE_TYPE.ELEMENT_NODE: {
let child = domSymbolTree.firstChild(this);
while (child) {
this.removeChild(child);
child = domSymbolTree.firstChild(this);
}
let child = domSymbolTree.firstChild(this);
while (child) {
this.removeChild(child);
child = domSymbolTree.firstChild(this);
}
if (value !== null && value !== "") {
this.appendChild(this._ownerDocument.createTextNode(value));
}
if (txt !== "" && txt !== null) {
this.appendChild(this._ownerDocument.createTextNode(txt));
break;
}
case NODE_TYPE.ATTRIBUTE_NODE: {
attributes.setAnExistingAttributeValue(this, value);
break;
}
case NODE_TYPE.TEXT_NODE:
case NODE_TYPE.CDATA_SECTION_NODE: // CDATASection is a subclass of Text
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
case NODE_TYPE.COMMENT_NODE: {
this.replaceData(0, this.length, value);
break;
}
}

@@ -472,0 +547,0 @@ }

{
"name": "jsdom",
"version": "11.8.0",
"version": "11.9.0",
"description": "A JavaScript implementation of many web standards",

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

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