jqtree 1.7.0 → 1.7.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.
Files changed (99) hide show
  1. package/.github/workflows/ci.yml +2 -15
  2. package/.github/workflows/codeql-analysis.yml +2 -2
  3. package/.github/workflows/size.yml +24 -0
  4. package/README.md +1 -1
  5. package/bower.json +1 -1
  6. package/docs/Gemfile.lock +39 -40
  7. package/docs/_config.yml +1 -1
  8. package/docs/_entries/03_features.md +1 -1
  9. package/docs/_entries/10_changelog.md +9 -0
  10. package/docs/_entries/16_closedicon.md +17 -3
  11. package/docs/_entries/31_openedicon.md +17 -3
  12. package/docs/package.json +7 -7
  13. package/docs/pnpm-lock.yaml +378 -284
  14. package/docs/static/bower.json +2 -2
  15. package/docs/static/bower_components/fontawesome/css/all.min.css +6 -2
  16. package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.ttf +0 -0
  17. package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
  18. package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.ttf +0 -0
  19. package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
  20. package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.ttf +0 -0
  21. package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
  22. package/docs/static/bower_components/fontawesome/webfonts/fa-v4compatibility.ttf +0 -0
  23. package/docs/static/bower_components/fontawesome/webfonts/fa-v4compatibility.woff2 +0 -0
  24. package/docs/static/bower_components/jquery/dist/jquery.js +813 -1102
  25. package/docs/static/bower_components/jquery/dist/jquery.min.js +2 -2
  26. package/docs/static/documentation.css +104 -222
  27. package/docs/static/examples/autoescape.js +15 -17
  28. package/docs/static/examples/autoscroll.js +5 -7
  29. package/docs/static/examples/button-on-right.js +4 -6
  30. package/docs/static/examples/custom_html.js +22 -24
  31. package/docs/static/examples/drag-outside.js +23 -25
  32. package/docs/static/examples/drag_and_drop.js +4 -6
  33. package/docs/static/examples/icon_buttons.js +3 -5
  34. package/docs/static/examples/load_json_data.js +14 -16
  35. package/docs/static/examples/load_json_data_from_server.js +1 -3
  36. package/docs/static/examples/load_on_demand.js +3 -5
  37. package/docs/static/examples/multiple_select.js +19 -21
  38. package/docs/static/examples/right-to-left.js +2 -4
  39. package/docs/static/examples/save_state.js +2 -4
  40. package/docs/tree.jquery.js +3 -3
  41. package/lib/dataLoader.js +3 -3
  42. package/lib/dragAndDropHandler.js +22 -11
  43. package/lib/elementsRenderer.js +26 -16
  44. package/lib/keyHandler.js +1 -1
  45. package/lib/mouse.widget.js +13 -2
  46. package/lib/node.js +17 -14
  47. package/lib/nodeElement.js +20 -13
  48. package/lib/playwright/coverage.js +11 -16
  49. package/lib/playwright/playwright.test.js +37 -58
  50. package/lib/playwright/testUtils.js +27 -44
  51. package/lib/saveStateHandler.js +2 -2
  52. package/lib/scrollHandler.js +8 -4
  53. package/lib/selectNodeHandler.js +2 -2
  54. package/lib/simple.widget.js +5 -3
  55. package/lib/test/jqTree/accessibility.test.js +37 -0
  56. package/lib/test/jqTree/events.test.js +73 -77
  57. package/lib/test/jqTree/loadOnDemand.test.js +5 -4
  58. package/lib/test/jqTree/methods.test.js +2 -2
  59. package/lib/test/jqTree/options.test.js +43 -2
  60. package/lib/test/node.test.js +7 -4
  61. package/lib/tree.jquery.js +5 -5
  62. package/lib/version.js +1 -1
  63. package/package.json +37 -41
  64. package/src/dragAndDropHandler.ts +24 -10
  65. package/src/elementsRenderer.ts +57 -50
  66. package/src/jqtreeOptions.ts +5 -5
  67. package/src/mouse.widget.ts +12 -0
  68. package/src/node.ts +10 -5
  69. package/src/nodeElement.ts +27 -21
  70. package/src/saveStateHandler.ts +1 -1
  71. package/src/scrollHandler.ts +6 -2
  72. package/src/selectNodeHandler.ts +1 -1
  73. package/src/simple.widget.ts +2 -0
  74. package/src/test/.eslintrc +2 -1
  75. package/src/test/jqTree/accessibility.test.ts +25 -0
  76. package/src/test/jqTree/events.test.ts +79 -93
  77. package/src/test/jqTree/loadOnDemand.test.ts +6 -5
  78. package/src/test/jqTree/methods.test.ts +27 -27
  79. package/src/test/jqTree/options.test.ts +61 -8
  80. package/src/test/node.test.ts +6 -4
  81. package/src/test/nodeUtil.test.ts +1 -1
  82. package/src/tree.jquery.d.ts +20 -11
  83. package/src/tree.jquery.ts +1 -1
  84. package/src/version.ts +1 -1
  85. package/tree.jquery.debug.js +143 -97
  86. package/tree.jquery.debug.js.map +1 -1
  87. package/tree.jquery.js +3 -3
  88. package/tree.jquery.js.map +1 -1
  89. package/tsconfig.json +1 -0
  90. package/.tool-versions +0 -1
  91. package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.eot +0 -0
  92. package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.svg +0 -3717
  93. package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
  94. package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.eot +0 -0
  95. package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.svg +0 -801
  96. package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
  97. package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.eot +0 -0
  98. package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.svg +0 -5028
  99. package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
@@ -1,7 +1,7 @@
1
1
  /*
2
- JqTree 1.7.0
2
+ JqTree 1.7.2
3
3
 
4
- Copyright 2022 Marco Braak
4
+ Copyright 2023 Marco Braak
5
5
 
6
6
  Licensed under the Apache License, Version 2.0 (the "License");
7
7
  you may not use this file except in compliance with the License.
@@ -20,62 +20,62 @@ limitations under the License.
20
20
  var jqtree = (function (exports) {
21
21
  'use strict';
22
22
 
23
- function _iterableToArrayLimit(arr, i) {
24
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
25
- if (null != _i) {
26
- var _s,
27
- _e,
28
- _x,
29
- _r,
30
- _arr = [],
31
- _n = !0,
32
- _d = !1;
23
+ function _iterableToArrayLimit(r, l) {
24
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
25
+ if (null != t) {
26
+ var e,
27
+ n,
28
+ i,
29
+ u,
30
+ a = [],
31
+ f = !0,
32
+ o = !1;
33
33
  try {
34
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
35
- if (Object(_i) !== _i) return;
36
- _n = !1;
37
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
38
- } catch (err) {
39
- _d = !0, _e = err;
34
+ if (i = (t = t.call(r)).next, 0 === l) {
35
+ if (Object(t) !== t) return;
36
+ f = !1;
37
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
38
+ } catch (r) {
39
+ o = !0, n = r;
40
40
  } finally {
41
41
  try {
42
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
42
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
43
43
  } finally {
44
- if (_d) throw _e;
44
+ if (o) throw n;
45
45
  }
46
46
  }
47
- return _arr;
47
+ return a;
48
48
  }
49
49
  }
50
- function ownKeys(object, enumerableOnly) {
51
- var keys = Object.keys(object);
50
+ function ownKeys(e, r) {
51
+ var t = Object.keys(e);
52
52
  if (Object.getOwnPropertySymbols) {
53
- var symbols = Object.getOwnPropertySymbols(object);
54
- enumerableOnly && (symbols = symbols.filter(function (sym) {
55
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
56
- })), keys.push.apply(keys, symbols);
53
+ var o = Object.getOwnPropertySymbols(e);
54
+ r && (o = o.filter(function (r) {
55
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
56
+ })), t.push.apply(t, o);
57
57
  }
58
- return keys;
58
+ return t;
59
59
  }
60
- function _objectSpread2(target) {
61
- for (var i = 1; i < arguments.length; i++) {
62
- var source = null != arguments[i] ? arguments[i] : {};
63
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
64
- _defineProperty(target, key, source[key]);
65
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
66
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
60
+ function _objectSpread2(e) {
61
+ for (var r = 1; r < arguments.length; r++) {
62
+ var t = null != arguments[r] ? arguments[r] : {};
63
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
64
+ _defineProperty(e, r, t[r]);
65
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
66
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
67
67
  });
68
68
  }
69
- return target;
69
+ return e;
70
70
  }
71
- function _typeof(obj) {
71
+ function _typeof(o) {
72
72
  "@babel/helpers - typeof";
73
73
 
74
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
75
- return typeof obj;
76
- } : function (obj) {
77
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
78
- }, _typeof(obj);
74
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
75
+ return typeof o;
76
+ } : function (o) {
77
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
78
+ }, _typeof(o);
79
79
  }
80
80
  function _classCallCheck(instance, Constructor) {
81
81
  if (!(instance instanceof Constructor)) {
@@ -292,15 +292,15 @@ var jqtree = (function (exports) {
292
292
  return typeof key === "symbol" ? key : String(key);
293
293
  }
294
294
 
295
- var version = "1.7.0";
295
+ var version = "1.7.2";
296
296
 
297
- var Position;
298
- (function (Position) {
297
+ var Position = /*#__PURE__*/function (Position) {
299
298
  Position[Position["Before"] = 1] = "Before";
300
299
  Position[Position["After"] = 2] = "After";
301
300
  Position[Position["Inside"] = 3] = "Inside";
302
301
  Position[Position["None"] = 4] = "None";
303
- })(Position || (Position = {}));
302
+ return Position;
303
+ }({});
304
304
  var positionNames = {
305
305
  before: Position.Before,
306
306
  after: Position.After,
@@ -777,7 +777,7 @@ var jqtree = (function (exports) {
777
777
  var _this = this;
778
778
  this.iterate(function (child) {
779
779
  var _this$tree;
780
- (_this$tree = _this.tree) === null || _this$tree === void 0 ? void 0 : _this$tree.removeNodeFromIndex(child);
780
+ (_this$tree = _this.tree) === null || _this$tree === void 0 || _this$tree.removeNodeFromIndex(child);
781
781
  return true;
782
782
  });
783
783
  this.children = [];
@@ -790,7 +790,7 @@ var jqtree = (function (exports) {
790
790
  } else {
791
791
  var previousIndex = this.parent.getChildIndex(this) - 1;
792
792
  if (previousIndex >= 0) {
793
- return this.parent.children[previousIndex];
793
+ return this.parent.children[previousIndex] || null;
794
794
  } else {
795
795
  return null;
796
796
  }
@@ -804,7 +804,7 @@ var jqtree = (function (exports) {
804
804
  } else {
805
805
  var nextIndex = this.parent.getChildIndex(this) + 1;
806
806
  if (nextIndex < this.parent.children.length) {
807
- return this.parent.children[nextIndex];
807
+ return this.parent.children[nextIndex] || null;
808
808
  } else {
809
809
  return null;
810
810
  }
@@ -834,7 +834,7 @@ var jqtree = (function (exports) {
834
834
  value: function getNextNode() {
835
835
  var includeChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
836
836
  if (includeChildren && this.hasChildren()) {
837
- return this.children[0];
837
+ return this.children[0] || null;
838
838
  } else if (!this.parent) {
839
839
  return null;
840
840
  } else {
@@ -851,7 +851,7 @@ var jqtree = (function (exports) {
851
851
  value: function getNextVisibleNode() {
852
852
  if (this.hasChildren() && this.is_open) {
853
853
  // First child
854
- return this.children[0];
854
+ return this.children[0] || null;
855
855
  } else {
856
856
  if (!this.parent) {
857
857
  return null;
@@ -921,10 +921,13 @@ var jqtree = (function (exports) {
921
921
  return null;
922
922
  } else {
923
923
  var lastChild = this.children[this.children.length - 1];
924
+ if (!lastChild) {
925
+ return null;
926
+ }
924
927
  if (!(lastChild.hasChildren() && lastChild.is_open)) {
925
928
  return lastChild;
926
929
  } else {
927
- return lastChild.getLastChild();
930
+ return lastChild === null || lastChild === void 0 ? void 0 : lastChild.getLastChild();
928
931
  }
929
932
  }
930
933
  }
@@ -964,20 +967,20 @@ var jqtree = (function (exports) {
964
967
  var _this$tree2;
965
968
  this.parent = parent;
966
969
  this.tree = parent.tree;
967
- (_this$tree2 = this.tree) === null || _this$tree2 === void 0 ? void 0 : _this$tree2.addNodeToIndex(this);
970
+ (_this$tree2 = this.tree) === null || _this$tree2 === void 0 || _this$tree2.addNodeToIndex(this);
968
971
  }
969
972
  }, {
970
973
  key: "doRemoveChild",
971
974
  value: function doRemoveChild(node) {
972
975
  var _this$tree3;
973
976
  this.children.splice(this.getChildIndex(node), 1);
974
- (_this$tree3 = this.tree) === null || _this$tree3 === void 0 ? void 0 : _this$tree3.removeNodeFromIndex(node);
977
+ (_this$tree3 = this.tree) === null || _this$tree3 === void 0 || _this$tree3.removeNodeFromIndex(node);
975
978
  }
976
979
  }, {
977
980
  key: "getNodeClass",
978
981
  value: function getNodeClass() {
979
982
  var _this$tree4;
980
- return this.nodeClass || (this === null || this === void 0 ? void 0 : (_this$tree4 = this.tree) === null || _this$tree4 === void 0 ? void 0 : _this$tree4.nodeClass) || Node;
983
+ return this.nodeClass || (this === null || this === void 0 || (_this$tree4 = this.tree) === null || _this$tree4 === void 0 ? void 0 : _this$tree4.nodeClass) || Node;
981
984
  }
982
985
  }, {
983
986
  key: "createNode",
@@ -1179,6 +1182,9 @@ var jqtree = (function (exports) {
1179
1182
  while (low < high) {
1180
1183
  var mid = low + high >> 1;
1181
1184
  var area = this.hitAreas[mid];
1185
+ if (!area) {
1186
+ return null;
1187
+ }
1182
1188
  if (y < area.top) {
1183
1189
  high = mid;
1184
1190
  } else if (y > area.bottom) {
@@ -1330,10 +1336,16 @@ var jqtree = (function (exports) {
1330
1336
  if (mustIterateInside) {
1331
1337
  var childrenLength = node.children.length;
1332
1338
  node.children.forEach(function (_, i) {
1333
- if (i === childrenLength - 1) {
1334
- _iterateNode(node.children[i], null);
1335
- } else {
1336
- _iterateNode(node.children[i], node.children[i + 1]);
1339
+ var child = node.children[i];
1340
+ if (child) {
1341
+ if (i === childrenLength - 1) {
1342
+ _iterateNode(child, null);
1343
+ } else {
1344
+ var nextChild = node.children[i + 1];
1345
+ if (nextChild) {
1346
+ _iterateNode(child, nextChild);
1347
+ }
1348
+ }
1337
1349
  }
1338
1350
  });
1339
1351
  if (node.is_open && $element) {
@@ -1492,12 +1504,14 @@ var jqtree = (function (exports) {
1492
1504
  var i = 0;
1493
1505
  while (i < positionCount) {
1494
1506
  var position = positionsInGroup[i];
1495
- hitAreas.push({
1496
- top: areaTop,
1497
- bottom: areaTop + areaHeight,
1498
- node: position.node,
1499
- position: position.position
1500
- });
1507
+ if (position) {
1508
+ hitAreas.push({
1509
+ top: areaTop,
1510
+ bottom: areaTop + areaHeight,
1511
+ node: position.node,
1512
+ position: position.position
1513
+ });
1514
+ }
1501
1515
  areaTop += areaHeight;
1502
1516
  i += 1;
1503
1517
  }
@@ -1573,7 +1587,9 @@ var jqtree = (function (exports) {
1573
1587
  value: function renderFromRoot() {
1574
1588
  var $element = this.treeWidget.element;
1575
1589
  $element.empty();
1576
- this.createDomElements($element[0], this.treeWidget.tree.children, true, 1);
1590
+ if ($element[0]) {
1591
+ this.createDomElements($element[0], this.treeWidget.tree.children, true, 1);
1592
+ }
1577
1593
  }
1578
1594
  }, {
1579
1595
  key: "renderFromNode",
@@ -1659,6 +1675,14 @@ var jqtree = (function (exports) {
1659
1675
  }
1660
1676
  return li;
1661
1677
  }
1678
+ }, {
1679
+ key: "setTreeItemAriaAttributes",
1680
+ value: function setTreeItemAriaAttributes(element, name, level, isSelected) {
1681
+ element.setAttribute("aria-label", name);
1682
+ element.setAttribute("aria-level", "".concat(level));
1683
+ element.setAttribute("aria-selected", getBoolString(isSelected));
1684
+ element.setAttribute("role", "treeitem");
1685
+ }
1662
1686
  }, {
1663
1687
  key: "createFolderLi",
1664
1688
  value: function createFolderLi(node, level, isSelected) {
@@ -1669,26 +1693,28 @@ var jqtree = (function (exports) {
1669
1693
  // li
1670
1694
  var li = document.createElement("li");
1671
1695
  li.className = "jqtree_common ".concat(folderClasses);
1672
- li.setAttribute("role", "presentation");
1696
+ li.setAttribute("role", "none");
1673
1697
 
1674
1698
  // div
1675
1699
  var div = document.createElement("div");
1676
1700
  div.className = "jqtree-element jqtree_common";
1677
- div.setAttribute("role", "presentation");
1701
+ div.setAttribute("role", "none");
1678
1702
  li.appendChild(div);
1679
1703
 
1680
1704
  // button link
1681
1705
  var buttonLink = document.createElement("a");
1682
1706
  buttonLink.className = buttonClasses;
1683
- buttonLink.appendChild(iconElement.cloneNode(true));
1684
- buttonLink.setAttribute("role", "presentation");
1685
- buttonLink.setAttribute("aria-hidden", "true");
1707
+ if (iconElement) {
1708
+ buttonLink.appendChild(iconElement.cloneNode(true));
1709
+ }
1686
1710
  if (this.treeWidget.options.buttonLeft) {
1687
1711
  div.appendChild(buttonLink);
1688
1712
  }
1689
1713
 
1690
1714
  // title span
1691
- div.appendChild(this.createTitleSpan(node.name, level, isSelected, node.is_open, true));
1715
+ var titleSpan = this.createTitleSpan(node.name, isSelected, true, level);
1716
+ titleSpan.setAttribute("aria-expanded", getBoolString(node.is_open));
1717
+ div.appendChild(titleSpan);
1692
1718
  if (!this.treeWidget.options.buttonLeft) {
1693
1719
  div.appendChild(buttonLink);
1694
1720
  }
@@ -1706,21 +1732,22 @@ var jqtree = (function (exports) {
1706
1732
  // li
1707
1733
  var li = document.createElement("li");
1708
1734
  li.className = classString;
1709
- li.setAttribute("role", "presentation");
1735
+ li.setAttribute("role", "none");
1710
1736
 
1711
1737
  // div
1712
1738
  var div = document.createElement("div");
1713
1739
  div.className = "jqtree-element jqtree_common";
1714
- div.setAttribute("role", "presentation");
1740
+ div.setAttribute("role", "none");
1715
1741
  li.appendChild(div);
1716
1742
 
1717
1743
  // title span
1718
- div.appendChild(this.createTitleSpan(node.name, level, isSelected, node.is_open, false));
1744
+ var titleSpan = this.createTitleSpan(node.name, isSelected, false, level);
1745
+ div.appendChild(titleSpan);
1719
1746
  return li;
1720
1747
  }
1721
1748
  }, {
1722
1749
  key: "createTitleSpan",
1723
- value: function createTitleSpan(nodeName, level, isSelected, isOpen, isFolder) {
1750
+ value: function createTitleSpan(nodeName, isSelected, isFolder, level) {
1724
1751
  var titleSpan = document.createElement("span");
1725
1752
  var classes = "jqtree-title jqtree_common";
1726
1753
  if (isFolder) {
@@ -1728,16 +1755,13 @@ var jqtree = (function (exports) {
1728
1755
  }
1729
1756
  classes += " jqtree-title-button-".concat(this.treeWidget.options.buttonLeft ? "left" : "right");
1730
1757
  titleSpan.className = classes;
1731
- titleSpan.setAttribute("role", "treeitem");
1732
- titleSpan.setAttribute("aria-level", "".concat(level));
1733
- titleSpan.setAttribute("aria-selected", getBoolString(isSelected));
1734
- titleSpan.setAttribute("aria-expanded", getBoolString(isOpen));
1735
1758
  if (isSelected) {
1736
1759
  var tabIndex = this.treeWidget.options.tabIndex;
1737
1760
  if (tabIndex !== undefined) {
1738
1761
  titleSpan.setAttribute("tabindex", "".concat(tabIndex));
1739
1762
  }
1740
1763
  }
1764
+ this.setTreeItemAriaAttributes(titleSpan, nodeName, level, isSelected);
1741
1765
  if (this.treeWidget.options.autoEscape) {
1742
1766
  titleSpan.textContent = nodeName;
1743
1767
  } else {
@@ -2101,6 +2125,8 @@ var jqtree = (function (exports) {
2101
2125
  }
2102
2126
  return callFunction(this, functionName, args);
2103
2127
  }
2128
+ } else {
2129
+ return undefined;
2104
2130
  }
2105
2131
  };
2106
2132
  };
@@ -2194,6 +2220,9 @@ var jqtree = (function (exports) {
2194
2220
  return;
2195
2221
  }
2196
2222
  var touch = e.changedTouches[0];
2223
+ if (!touch) {
2224
+ return;
2225
+ }
2197
2226
  _this.handleMouseDown(getPositionInfoFromTouch(touch, e));
2198
2227
  });
2199
2228
  _defineProperty(_assertThisInitialized(_this), "touchMove", function (e) {
@@ -2204,6 +2233,9 @@ var jqtree = (function (exports) {
2204
2233
  return;
2205
2234
  }
2206
2235
  var touch = e.changedTouches[0];
2236
+ if (!touch) {
2237
+ return;
2238
+ }
2207
2239
  _this.handleMouseMove(e, getPositionInfoFromTouch(touch, e));
2208
2240
  });
2209
2241
  _defineProperty(_assertThisInitialized(_this), "touchEnd", function (e) {
@@ -2214,6 +2246,9 @@ var jqtree = (function (exports) {
2214
2246
  return;
2215
2247
  }
2216
2248
  var touch = e.changedTouches[0];
2249
+ if (!touch) {
2250
+ return;
2251
+ }
2217
2252
  _this.handleMouseUp(getPositionInfoFromTouch(touch, e));
2218
2253
  });
2219
2254
  return _this;
@@ -2454,7 +2489,7 @@ var jqtree = (function (exports) {
2454
2489
  value: function getNodeIdToBeSelected() {
2455
2490
  var state = this.getStateFromStorage();
2456
2491
  if (state && state.selected_node) {
2457
- return state.selected_node[0];
2492
+ return state.selected_node[0] || null;
2458
2493
  } else {
2459
2494
  return null;
2460
2495
  }
@@ -2646,7 +2681,7 @@ var jqtree = (function (exports) {
2646
2681
  key: "scrollToY",
2647
2682
  value: function scrollToY(top) {
2648
2683
  this.ensureInit();
2649
- if (this.$scrollParent) {
2684
+ if (this.$scrollParent && this.$scrollParent[0]) {
2650
2685
  this.$scrollParent[0].scrollTop = top;
2651
2686
  } else {
2652
2687
  var offset = this.treeWidget.$el.offset();
@@ -2692,7 +2727,8 @@ var jqtree = (function (exports) {
2692
2727
  }, {
2693
2728
  key: "initScrollParent",
2694
2729
  value: function initScrollParent() {
2695
- var _this = this;
2730
+ var _this = this,
2731
+ _$scrollParent$;
2696
2732
  var getParentWithOverflow = function getParentWithOverflow() {
2697
2733
  var cssAttributes = ["overflow", "overflow-y"];
2698
2734
  var hasOverFlow = function hasOverFlow($el) {
@@ -2733,7 +2769,7 @@ var jqtree = (function (exports) {
2733
2769
  setDocumentAsScrollParent();
2734
2770
  }
2735
2771
  var $scrollParent = getParentWithOverflow();
2736
- if ($scrollParent && $scrollParent.length && $scrollParent[0].tagName !== "HTML") {
2772
+ if ($scrollParent && $scrollParent.length && ((_$scrollParent$ = $scrollParent[0]) === null || _$scrollParent$ === void 0 ? void 0 : _$scrollParent$.tagName) !== "HTML") {
2737
2773
  this.$scrollParent = $scrollParent;
2738
2774
  var offset = this.$scrollParent.offset();
2739
2775
  this.scrollParentTop = offset ? offset.top : 0;
@@ -2819,6 +2855,9 @@ var jqtree = (function (exports) {
2819
2855
  return;
2820
2856
  }
2821
2857
  var scrollParent = $scrollParent[0];
2858
+ if (!scrollParent) {
2859
+ return;
2860
+ }
2822
2861
  var canScrollRight = scrollParent.scrollLeft + scrollParent.clientWidth < scrollParent.scrollWidth;
2823
2862
  var canScrollLeft = scrollParent.scrollLeft > 0;
2824
2863
  var rightEdge = scrollParentOffset.left + scrollParent.clientWidth;
@@ -2868,7 +2907,7 @@ var jqtree = (function (exports) {
2868
2907
  value: function getSelectedNode() {
2869
2908
  var selectedNodes = this.getSelectedNodes();
2870
2909
  if (selectedNodes.length) {
2871
- return selectedNodes[0];
2910
+ return selectedNodes[0] || false;
2872
2911
  } else {
2873
2912
  return false;
2874
2913
  }
@@ -3007,9 +3046,9 @@ var jqtree = (function (exports) {
3007
3046
  var _this$treeWidget$opti;
3008
3047
  var $li = this.getLi();
3009
3048
  $li.addClass("jqtree-selected");
3010
- $li.attr("aria-selected", "true");
3011
3049
  var $span = this.getSpan();
3012
3050
  $span.attr("tabindex", (_this$treeWidget$opti = this.treeWidget.options.tabIndex) !== null && _this$treeWidget$opti !== void 0 ? _this$treeWidget$opti : null);
3051
+ $span.attr("aria-selected", "true");
3013
3052
  if (mustSetFocus) {
3014
3053
  $span.trigger("focus");
3015
3054
  }
@@ -3019,10 +3058,10 @@ var jqtree = (function (exports) {
3019
3058
  value: function deselect() {
3020
3059
  var $li = this.getLi();
3021
3060
  $li.removeClass("jqtree-selected");
3022
- $li.attr("aria-selected", "false");
3023
3061
  var $span = this.getSpan();
3024
3062
  $span.removeAttr("tabindex");
3025
- $span.blur();
3063
+ $span.attr("aria-selected", "false");
3064
+ $span.trigger("blur");
3026
3065
  }
3027
3066
  }, {
3028
3067
  key: "getUl",
@@ -3069,14 +3108,17 @@ var jqtree = (function (exports) {
3069
3108
  $button.html("");
3070
3109
  var buttonEl = $button.get(0);
3071
3110
  if (buttonEl) {
3072
- var icon = this.treeWidget.renderer.openedIconElement.cloneNode(true);
3073
- buttonEl.appendChild(icon);
3111
+ var openedIconElement = this.treeWidget.renderer.openedIconElement;
3112
+ if (openedIconElement) {
3113
+ var icon = openedIconElement.cloneNode(true);
3114
+ buttonEl.appendChild(icon);
3115
+ }
3074
3116
  }
3075
3117
  var doOpen = function doOpen() {
3076
3118
  var $li = _this.getLi();
3077
3119
  $li.removeClass("jqtree-closed");
3078
- var $span = _this.getSpan();
3079
- $span.attr("aria-expanded", "true");
3120
+ var $titleSpan = _this.getSpan();
3121
+ $titleSpan.attr("aria-expanded", "true");
3080
3122
  if (onFinished) {
3081
3123
  onFinished(_this.node);
3082
3124
  }
@@ -3106,14 +3148,17 @@ var jqtree = (function (exports) {
3106
3148
  $button.html("");
3107
3149
  var buttonEl = $button.get(0);
3108
3150
  if (buttonEl) {
3109
- var icon = this.treeWidget.renderer.closedIconElement.cloneNode(true);
3110
- buttonEl.appendChild(icon);
3151
+ var closedIconElement = this.treeWidget.renderer.closedIconElement;
3152
+ if (closedIconElement) {
3153
+ var icon = closedIconElement.cloneNode(true);
3154
+ buttonEl.appendChild(icon);
3155
+ }
3111
3156
  }
3112
3157
  var doClose = function doClose() {
3113
3158
  var $li = _this2.getLi();
3114
3159
  $li.addClass("jqtree-closed");
3115
- var $span = _this2.getSpan();
3116
- $span.attr("aria-expanded", "false");
3160
+ var $titleSpan = _this2.getSpan();
3161
+ $titleSpan.attr("aria-expanded", "false");
3117
3162
  _this2.treeWidget._triggerEvent("tree.close", {
3118
3163
  node: _this2.node
3119
3164
  });
@@ -3201,7 +3246,8 @@ var jqtree = (function (exports) {
3201
3246
  }, {
3202
3247
  key: "moveInsideOpenFolder",
3203
3248
  value: function moveInsideOpenFolder() {
3204
- var childElement = this.node.children[0].element;
3249
+ var _this$node$children$;
3250
+ var childElement = (_this$node$children$ = this.node.children[0]) === null || _this$node$children$ === void 0 ? void 0 : _this$node$children$.element;
3205
3251
  if (childElement) {
3206
3252
  jQuery(childElement).before(this.$ghost);
3207
3253
  }