New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

happy-dom

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

happy-dom - npm Package Compare versions

Comparing version

to
1.2.0

@@ -147,2 +147,8 @@ import Document from '../document/Document';

/**
* The Node.replaceWith() method replaces this Node in the children list of its parent with a set of Node or DOMString objects.
*
* @param nodes List of Node or DOMString.
*/
replaceWith(...nodes: Node[] | string[]): void;
/**
* @override

@@ -149,0 +155,0 @@ */

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

})();
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -24,2 +31,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var MutationType_1 = __importDefault(require("../../../mutation-observer/MutationType"));
var HTMLParser_1 = __importDefault(require("../../../html-parser/HTMLParser"));
var CLONE_REFERENCE_PROPERTIES = [

@@ -435,2 +443,30 @@ 'ownerDocument',

/**
* The Node.replaceWith() method replaces this Node in the children list of its parent with a set of Node or DOMString objects.
*
* @param nodes List of Node or DOMString.
*/
Node.prototype.replaceWith = function () {
var _a;
var nodes = [];
for (var _i = 0; _i < arguments.length; _i++) {
nodes[_i] = arguments[_i];
}
var parent = this.parentNode;
if (!parent) {
return;
}
var index = parent.childNodes.indexOf(this);
parent.removeChild(this);
for (var i = nodes.length - 1; i >= 0; i--) {
var node = nodes[i];
if (typeof node === 'string') {
(_a = parent.childNodes).splice.apply(_a, __spreadArrays([index,
0], HTMLParser_1.default.parse(this.ownerDocument, node).childNodes));
}
else {
parent.childNodes.splice(index, 0, node);
}
}
};
/**
* @override

@@ -437,0 +473,0 @@ */

{
"name": "happy-dom",
"version": "1.1.15",
"version": "1.2.0",
"license": "MIT",

@@ -62,3 +62,3 @@ "homepage": "https://github.com/capricorn86/happy-dom",

},
"gitHead": "fb8d1cdbe2f3ffb158ec793148ffae4057168b9e"
"gitHead": "0b752bee12f9f16a050c2679fc0dce155729bb4c"
}

@@ -8,2 +8,3 @@ import Document from '../document/Document';

import Event from '../../../event/Event';
import HTMLParser from '../../../html-parser/HTMLParser';

@@ -426,2 +427,33 @@ const CLONE_REFERENCE_PROPERTIES = [

/**
* The Node.replaceWith() method replaces this Node in the children list of its parent with a set of Node or DOMString objects.
*
* @param nodes List of Node or DOMString.
*/
public replaceWith(...nodes: Node[] | string[]): void {
const parent = this.parentNode;
if (!parent) {
return;
}
const index = parent.childNodes.indexOf(this);
parent.removeChild(this);
for (let i = nodes.length - 1; i >= 0; i--) {
const node = nodes[i];
if (typeof node === 'string') {
parent.childNodes.splice(
index,
0,
...HTMLParser.parse(this.ownerDocument, node).childNodes
);
} else {
parent.childNodes.splice(index, 0, node);
}
}
}
/**
* @override

@@ -428,0 +460,0 @@ */

Sorry, the diff of this file is not supported yet