node-html-parser 5.3.1 → 5.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -73,6 +73,20 @@ define("nodes/node", ["require", "exports", "he"], function (require, exports, h
73
73
  value: range !== null && range !== void 0 ? range : [-1, -1]
74
74
  });
75
75
  }
76
+ /**
77
+ * Remove current node
78
+ */
79
+ Node.prototype.remove = function () {
80
+ var _this = this;
81
+ if (this.parentNode) {
82
+ var children = this.parentNode.childNodes;
83
+ this.parentNode.childNodes = children.filter(function (child) {
84
+ return _this !== child;
85
+ });
86
+ this.parentNode = null;
87
+ }
88
+ return this;
89
+ };
76
90
  Object.defineProperty(Node.prototype, "innerText", {
77
91
  get: function () {
78
92
  return this.rawText;
@@ -485,20 +499,6 @@ define("nodes/html", ["require", "exports", "css-select", "he", "back", "matcher
485
499
  }
486
500
  return JSON.stringify(attr.replace(/"/g, '"'));
487
501
  };
488
- /**
489
- * Remove current element
490
- */
491
- HTMLElement.prototype.remove = function () {
492
- var _this = this;
493
- if (this.parentNode) {
494
- var children = this.parentNode.childNodes;
495
- this.parentNode.childNodes = children.filter(function (child) {
496
- return _this !== child;
497
- });
498
- this.parentNode = null;
499
- }
500
- return this;
501
- };
502
502
  /**
503
503
  * Remove Child element from childNodes array
504
504
  * @param {HTMLElement} node node to remove
@@ -936,7 +936,8 @@ define("nodes/html", ["require", "exports", "css-select", "he", "back", "matcher
936
936
  * @return {Node} node appended
937
937
  */
938
938
  HTMLElement.prototype.appendChild = function (node) {
939
- // node.parentNode = this;
939
+ // remove the node from it's parent
940
+ node.remove();
940
941
  this.childNodes.push(node);
941
942
  node.parentNode = this;
942
943
  return node;
@@ -60,10 +60,6 @@ export default class HTMLElement extends Node {
60
60
  * @memberof HTMLElement
61
61
  */
62
62
  constructor(tagName: string, keyAttrs: KeyAttributes, rawAttrs: string, parentNode: HTMLElement | null, range?: [number, number]);
63
- /**
64
- * Remove current element
65
- */
66
- remove(): this;
67
63
  /**
68
64
  * Remove Child element from childNodes array
69
65
  * @param {HTMLElement} node node to remove
@@ -197,20 +197,6 @@ var HTMLElement = /** @class */ (function (_super) {
197
197
  }
198
198
  return JSON.stringify(attr.replace(/"/g, '"'));
199
199
  };
200
- /**
201
- * Remove current element
202
- */
203
- HTMLElement.prototype.remove = function () {
204
- var _this = this;
205
- if (this.parentNode) {
206
- var children = this.parentNode.childNodes;
207
- this.parentNode.childNodes = children.filter(function (child) {
208
- return _this !== child;
209
- });
210
- this.parentNode = null;
211
- }
212
- return this;
213
- };
214
200
  /**
215
201
  * Remove Child element from childNodes array
216
202
  * @param {HTMLElement} node node to remove
@@ -648,7 +634,8 @@ var HTMLElement = /** @class */ (function (_super) {
648
634
  * @return {Node} node appended
649
635
  */
650
636
  HTMLElement.prototype.appendChild = function (node) {
651
- // node.parentNode = this;
637
+ // remove the node from it's parent
638
+ node.remove();
652
639
  this.childNodes.push(node);
653
640
  node.parentNode = this;
654
641
  return node;
@@ -13,6 +13,10 @@ export default abstract class Node {
13
13
  abstract toString(): string;
14
14
  abstract clone(): Node;
15
15
  constructor(parentNode?: HTMLElement, range?: [number, number]);
16
+ /**
17
+ * Remove current node
18
+ */
19
+ remove(): this;
16
20
  get innerText(): string;
17
21
  get textContent(): string;
18
22
  set textContent(val: string);
@@ -16,6 +16,20 @@ var Node = /** @class */ (function () {
16
16
  value: range !== null && range !== void 0 ? range : [-1, -1]
17
17
  });
18
18
  }
19
+ /**
20
+ * Remove current node
21
+ */
22
+ Node.prototype.remove = function () {
23
+ var _this = this;
24
+ if (this.parentNode) {
25
+ var children = this.parentNode.childNodes;
26
+ this.parentNode.childNodes = children.filter(function (child) {
27
+ return _this !== child;
28
+ });
29
+ this.parentNode = null;
30
+ }
31
+ return this;
32
+ };
19
33
  Object.defineProperty(Node.prototype, "innerText", {
20
34
  get: function () {
21
35
  return this.rawText;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-html-parser",
3
- "version": "5.3.1",
3
+ "version": "5.3.2",
4
4
  "description": "A very fast HTML parser, generating a simplified DOM, with basic element query support.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",