node-html-parser 4.1.2 → 4.1.3

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
@@ -27,10 +27,14 @@ var __assign = (this && this.__assign) || function () {
27
27
  };
28
28
  return __assign.apply(this, arguments);
29
29
  };
30
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
31
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
32
- to[j] = from[i];
33
- return to;
30
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
31
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
32
+ if (ar || !(i in from)) {
33
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
34
+ ar[i] = from[i];
35
+ }
36
+ }
37
+ return to.concat(ar || from);
34
38
  };
35
39
  define("back", ["require", "exports"], function (require, exports) {
36
40
  "use strict";
@@ -119,7 +123,7 @@ define("nodes/text", ["require", "exports", "he", "nodes/node", "nodes/type"], f
119
123
  * @return {string} text content
120
124
  */
121
125
  get: function () {
122
- return he_1.decode(this.rawText);
126
+ return (0, he_1.decode)(this.rawText);
123
127
  },
124
128
  enumerable: false,
125
129
  configurable: true
@@ -680,7 +684,7 @@ define("nodes/html", ["require", "exports", "he", "css-select", "nodes/node", "n
680
684
  var idx = this.parentNode.childNodes.findIndex(function (child) {
681
685
  return child === _this;
682
686
  });
683
- this.parentNode.childNodes = __spreadArray(__spreadArray(__spreadArray([], this.parentNode.childNodes.slice(0, idx)), content), this.parentNode.childNodes.slice(idx + 1));
687
+ this.parentNode.childNodes = __spreadArray(__spreadArray(__spreadArray([], this.parentNode.childNodes.slice(0, idx), true), content, true), this.parentNode.childNodes.slice(idx + 1), true);
684
688
  };
685
689
  Object.defineProperty(HTMLElement.prototype, "outerHTML", {
686
690
  get: function () {
@@ -773,7 +777,7 @@ define("nodes/html", ["require", "exports", "he", "css-select", "nodes/node", "n
773
777
  * @return {HTMLElement[]} matching elements
774
778
  */
775
779
  HTMLElement.prototype.querySelectorAll = function (selector) {
776
- return css_select_1.selectAll(selector, this, {
780
+ return (0, css_select_1.selectAll)(selector, this, {
777
781
  xmlMode: true,
778
782
  adapter: matcher_1.default
779
783
  });
@@ -841,7 +845,7 @@ define("nodes/html", ["require", "exports", "he", "css-select", "nodes/node", "n
841
845
  * @return {HTMLElement} matching node
842
846
  */
843
847
  HTMLElement.prototype.querySelector = function (selector) {
844
- return css_select_1.selectOne(selector, this, {
848
+ return (0, css_select_1.selectOne)(selector, this, {
845
849
  xmlMode: true,
846
850
  adapter: matcher_1.default
847
851
  });
@@ -914,17 +918,14 @@ define("nodes/html", ["require", "exports", "he", "css-select", "nodes/node", "n
914
918
  }
915
919
  el = this;
916
920
  while (el) {
917
- var e = css_select_1.selectOne(selector, el, {
921
+ var e = (0, css_select_1.selectOne)(selector, el, {
918
922
  xmlMode: true,
919
923
  adapter: __assign(__assign({}, matcher_1.default), { getChildren: function (node) {
920
924
  var child = mapChild.get(node);
921
925
  return child && [child];
922
- },
923
- getSiblings: function (node) {
926
+ }, getSiblings: function (node) {
924
927
  return [node];
925
- },
926
- findOne: findOne,
927
- findAll: function () {
928
+ }, findOne: findOne, findAll: function () {
928
929
  return [];
929
930
  } })
930
931
  });
@@ -963,7 +964,7 @@ define("nodes/html", ["require", "exports", "he", "css-select", "nodes/node", "n
963
964
  * @return {Node} last child node
964
965
  */
965
966
  get: function () {
966
- return back_1.default(this.childNodes);
967
+ return (0, back_1.default)(this.childNodes);
967
968
  },
968
969
  enumerable: false,
969
970
  configurable: true
@@ -1125,7 +1126,7 @@ define("nodes/html", ["require", "exports", "he", "css-select", "nodes/node", "n
1125
1126
  var idx = this.parentNode.childNodes.findIndex(function (child) {
1126
1127
  return child === _this;
1127
1128
  });
1128
- (_a = this.parentNode.childNodes).splice.apply(_a, __spreadArray([idx + 1, 0], p.childNodes));
1129
+ (_a = this.parentNode.childNodes).splice.apply(_a, __spreadArray([idx + 1, 0], p.childNodes, false));
1129
1130
  p.childNodes.forEach(function (n) {
1130
1131
  if (n instanceof HTMLElement) {
1131
1132
  n.parentNode = _this.parentNode;
@@ -1144,7 +1145,7 @@ define("nodes/html", ["require", "exports", "he", "css-select", "nodes/node", "n
1144
1145
  var idx = this.parentNode.childNodes.findIndex(function (child) {
1145
1146
  return child === _this;
1146
1147
  });
1147
- (_c = this.parentNode.childNodes).splice.apply(_c, __spreadArray([idx, 0], p.childNodes));
1148
+ (_c = this.parentNode.childNodes).splice.apply(_c, __spreadArray([idx, 0], p.childNodes, false));
1148
1149
  p.childNodes.forEach(function (n) {
1149
1150
  if (n instanceof HTMLElement) {
1150
1151
  n.parentNode = _this.parentNode;
@@ -1370,7 +1371,7 @@ define("nodes/html", ["require", "exports", "he", "css-select", "nodes/node", "n
1370
1371
  if (!match[4] && kElementsClosedByOpening[tagName]) {
1371
1372
  if (kElementsClosedByOpening[tagName][match[2]]) {
1372
1373
  stack.pop();
1373
- currentParent = back_1.default(stack);
1374
+ currentParent = (0, back_1.default)(stack);
1374
1375
  }
1375
1376
  }
1376
1377
  var tagEndPos_1 = kMarkupPattern.lastIndex;
@@ -1409,7 +1410,7 @@ define("nodes/html", ["require", "exports", "he", "css-select", "nodes/node", "n
1409
1410
  // Update range end for closed tag
1410
1411
  currentParent.range[1] = createRange(-1, Math.max(lastTextPos, tagEndPos))[1];
1411
1412
  stack.pop();
1412
- currentParent = back_1.default(stack);
1413
+ currentParent = (0, back_1.default)(stack);
1413
1414
  break;
1414
1415
  }
1415
1416
  else {
@@ -1418,7 +1419,7 @@ define("nodes/html", ["require", "exports", "he", "css-select", "nodes/node", "n
1418
1419
  if (kElementsClosedByClosing[tagName]) {
1419
1420
  if (kElementsClosedByClosing[tagName][match[2]]) {
1420
1421
  stack.pop();
1421
- currentParent = back_1.default(stack);
1422
+ currentParent = (0, back_1.default)(stack);
1422
1423
  continue;
1423
1424
  }
1424
1425
  }
@@ -1442,7 +1443,7 @@ define("nodes/html", ["require", "exports", "he", "css-select", "nodes/node", "n
1442
1443
  var _loop_1 = function () {
1443
1444
  // Handle each error elements.
1444
1445
  var last = stack.pop();
1445
- var oneBefore = back_1.default(stack);
1446
+ var oneBefore = (0, back_1.default)(stack);
1446
1447
  if (last.parentNode && last.parentNode.parentNode) {
1447
1448
  if (last.parentNode === oneBefore && last.tagName === oneBefore.tagName) {
1448
1449
  // Pair error case <h3> <h3> handle : Fixes to <h3> </h3>
@@ -1503,10 +1504,10 @@ define("nodes/node", ["require", "exports", "he"], function (require, exports, h
1503
1504
  });
1504
1505
  Object.defineProperty(Node.prototype, "textContent", {
1505
1506
  get: function () {
1506
- return he_3.decode(this.rawText);
1507
+ return (0, he_3.decode)(this.rawText);
1507
1508
  },
1508
1509
  set: function (val) {
1509
- this.rawText = he_3.encode(val);
1510
+ this.rawText = (0, he_3.encode)(val);
1510
1511
  },
1511
1512
  enumerable: false,
1512
1513
  configurable: true
@@ -1565,7 +1566,7 @@ define("valid", ["require", "exports", "nodes/html"], function (require, exports
1565
1566
  */
1566
1567
  function valid(data, options) {
1567
1568
  if (options === void 0) { options = { lowerCaseTagName: false, comment: false }; }
1568
- var stack = html_2.base_parse(data, options);
1569
+ var stack = (0, html_2.base_parse)(data, options);
1569
1570
  return Boolean(stack.length === 1);
1570
1571
  }
1571
1572
  exports.default = valid;
@@ -14,5 +14,5 @@ export default class CommentNode extends Node {
14
14
  * @return {string} text content
15
15
  */
16
16
  get text(): string;
17
- toString(): `<!--${string}-->`;
17
+ toString(): string;
18
18
  }
@@ -25,10 +25,14 @@ var __assign = (this && this.__assign) || function () {
25
25
  };
26
26
  return __assign.apply(this, arguments);
27
27
  };
28
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
29
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
30
- to[j] = from[i];
31
- return to;
28
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
29
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
+ if (ar || !(i in from)) {
31
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
32
+ ar[i] = from[i];
33
+ }
34
+ }
35
+ return to.concat(ar || from);
32
36
  };
33
37
  var __importDefault = (this && this.__importDefault) || function (mod) {
34
38
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -434,7 +438,7 @@ var HTMLElement = /** @class */ (function (_super) {
434
438
  var idx = this.parentNode.childNodes.findIndex(function (child) {
435
439
  return child === _this;
436
440
  });
437
- this.parentNode.childNodes = __spreadArray(__spreadArray(__spreadArray([], this.parentNode.childNodes.slice(0, idx)), content), this.parentNode.childNodes.slice(idx + 1));
441
+ this.parentNode.childNodes = __spreadArray(__spreadArray(__spreadArray([], this.parentNode.childNodes.slice(0, idx), true), content, true), this.parentNode.childNodes.slice(idx + 1), true);
438
442
  };
439
443
  Object.defineProperty(HTMLElement.prototype, "outerHTML", {
440
444
  get: function () {
@@ -527,7 +531,7 @@ var HTMLElement = /** @class */ (function (_super) {
527
531
  * @return {HTMLElement[]} matching elements
528
532
  */
529
533
  HTMLElement.prototype.querySelectorAll = function (selector) {
530
- return css_select_1.selectAll(selector, this, {
534
+ return (0, css_select_1.selectAll)(selector, this, {
531
535
  xmlMode: true,
532
536
  adapter: matcher_1.default
533
537
  });
@@ -595,7 +599,7 @@ var HTMLElement = /** @class */ (function (_super) {
595
599
  * @return {HTMLElement} matching node
596
600
  */
597
601
  HTMLElement.prototype.querySelector = function (selector) {
598
- return css_select_1.selectOne(selector, this, {
602
+ return (0, css_select_1.selectOne)(selector, this, {
599
603
  xmlMode: true,
600
604
  adapter: matcher_1.default
601
605
  });
@@ -668,17 +672,14 @@ var HTMLElement = /** @class */ (function (_super) {
668
672
  }
669
673
  el = this;
670
674
  while (el) {
671
- var e = css_select_1.selectOne(selector, el, {
675
+ var e = (0, css_select_1.selectOne)(selector, el, {
672
676
  xmlMode: true,
673
677
  adapter: __assign(__assign({}, matcher_1.default), { getChildren: function (node) {
674
678
  var child = mapChild.get(node);
675
679
  return child && [child];
676
- },
677
- getSiblings: function (node) {
680
+ }, getSiblings: function (node) {
678
681
  return [node];
679
- },
680
- findOne: findOne,
681
- findAll: function () {
682
+ }, findOne: findOne, findAll: function () {
682
683
  return [];
683
684
  } })
684
685
  });
@@ -717,7 +718,7 @@ var HTMLElement = /** @class */ (function (_super) {
717
718
  * @return {Node} last child node
718
719
  */
719
720
  get: function () {
720
- return back_1.default(this.childNodes);
721
+ return (0, back_1.default)(this.childNodes);
721
722
  },
722
723
  enumerable: false,
723
724
  configurable: true
@@ -879,7 +880,7 @@ var HTMLElement = /** @class */ (function (_super) {
879
880
  var idx = this.parentNode.childNodes.findIndex(function (child) {
880
881
  return child === _this;
881
882
  });
882
- (_a = this.parentNode.childNodes).splice.apply(_a, __spreadArray([idx + 1, 0], p.childNodes));
883
+ (_a = this.parentNode.childNodes).splice.apply(_a, __spreadArray([idx + 1, 0], p.childNodes, false));
883
884
  p.childNodes.forEach(function (n) {
884
885
  if (n instanceof HTMLElement) {
885
886
  n.parentNode = _this.parentNode;
@@ -898,7 +899,7 @@ var HTMLElement = /** @class */ (function (_super) {
898
899
  var idx = this.parentNode.childNodes.findIndex(function (child) {
899
900
  return child === _this;
900
901
  });
901
- (_c = this.parentNode.childNodes).splice.apply(_c, __spreadArray([idx, 0], p.childNodes));
902
+ (_c = this.parentNode.childNodes).splice.apply(_c, __spreadArray([idx, 0], p.childNodes, false));
902
903
  p.childNodes.forEach(function (n) {
903
904
  if (n instanceof HTMLElement) {
904
905
  n.parentNode = _this.parentNode;
@@ -1124,7 +1125,7 @@ function base_parse(data, options) {
1124
1125
  if (!match[4] && kElementsClosedByOpening[tagName]) {
1125
1126
  if (kElementsClosedByOpening[tagName][match[2]]) {
1126
1127
  stack.pop();
1127
- currentParent = back_1.default(stack);
1128
+ currentParent = (0, back_1.default)(stack);
1128
1129
  }
1129
1130
  }
1130
1131
  var tagEndPos_1 = kMarkupPattern.lastIndex;
@@ -1163,7 +1164,7 @@ function base_parse(data, options) {
1163
1164
  // Update range end for closed tag
1164
1165
  currentParent.range[1] = createRange(-1, Math.max(lastTextPos, tagEndPos))[1];
1165
1166
  stack.pop();
1166
- currentParent = back_1.default(stack);
1167
+ currentParent = (0, back_1.default)(stack);
1167
1168
  break;
1168
1169
  }
1169
1170
  else {
@@ -1172,7 +1173,7 @@ function base_parse(data, options) {
1172
1173
  if (kElementsClosedByClosing[tagName]) {
1173
1174
  if (kElementsClosedByClosing[tagName][match[2]]) {
1174
1175
  stack.pop();
1175
- currentParent = back_1.default(stack);
1176
+ currentParent = (0, back_1.default)(stack);
1176
1177
  continue;
1177
1178
  }
1178
1179
  }
@@ -1196,7 +1197,7 @@ function parse(data, options) {
1196
1197
  var _loop_1 = function () {
1197
1198
  // Handle each error elements.
1198
1199
  var last = stack.pop();
1199
- var oneBefore = back_1.default(stack);
1200
+ var oneBefore = (0, back_1.default)(stack);
1200
1201
  if (last.parentNode && last.parentNode.parentNode) {
1201
1202
  if (last.parentNode === oneBefore && last.tagName === oneBefore.tagName) {
1202
1203
  // Pair error case <h3> <h3> handle : Fixes to <h3> </h3>
@@ -25,10 +25,10 @@ var Node = /** @class */ (function () {
25
25
  });
26
26
  Object.defineProperty(Node.prototype, "textContent", {
27
27
  get: function () {
28
- return he_1.decode(this.rawText);
28
+ return (0, he_1.decode)(this.rawText);
29
29
  },
30
30
  set: function (val) {
31
- this.rawText = he_1.encode(val);
31
+ this.rawText = (0, he_1.encode)(val);
32
32
  },
33
33
  enumerable: false,
34
34
  configurable: true
@@ -84,7 +84,7 @@ var TextNode = /** @class */ (function (_super) {
84
84
  * @return {string} text content
85
85
  */
86
86
  get: function () {
87
- return he_1.decode(this.rawText);
87
+ return (0, he_1.decode)(this.rawText);
88
88
  },
89
89
  enumerable: false,
90
90
  configurable: true
package/dist/valid.js CHANGED
@@ -7,7 +7,7 @@ var html_1 = require("./nodes/html");
7
7
  */
8
8
  function valid(data, options) {
9
9
  if (options === void 0) { options = { lowerCaseTagName: false, comment: false }; }
10
- var stack = html_1.base_parse(data, options);
10
+ var stack = (0, html_1.base_parse)(data, options);
11
11
  return Boolean(stack.length === 1);
12
12
  }
13
13
  exports.default = valid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-html-parser",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
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
  "module": "dist/esm/index.js",