jqtree 1.7.0 → 1.7.1
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/.github/workflows/ci.yml +2 -10
- package/.github/workflows/codeql-analysis.yml +2 -2
- package/bower.json +1 -1
- package/docs/Gemfile.lock +34 -37
- package/docs/_config.yml +1 -1
- package/docs/_entries/10_changelog.md +4 -0
- package/docs/package.json +7 -7
- package/docs/pnpm-lock.yaml +387 -269
- package/docs/static/bower.json +2 -2
- package/docs/static/bower_components/fontawesome/css/all.min.css +6 -2
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-v4compatibility.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-v4compatibility.woff2 +0 -0
- package/docs/static/bower_components/jquery/dist/jquery.js +813 -1102
- package/docs/static/bower_components/jquery/dist/jquery.min.js +2 -2
- package/docs/static/documentation.css +104 -222
- package/docs/tree.jquery.js +3 -3
- package/lib/dragAndDropHandler.js +21 -10
- package/lib/elementsRenderer.js +25 -15
- package/lib/mouse.widget.js +12 -1
- package/lib/node.js +13 -10
- package/lib/nodeElement.js +19 -12
- package/lib/saveStateHandler.js +1 -1
- package/lib/scrollHandler.js +7 -3
- package/lib/selectNodeHandler.js +1 -1
- package/lib/simple.widget.js +2 -0
- package/lib/test/jqTree/accessibility.test.js +37 -0
- package/lib/test/jqTree/events.test.js +73 -77
- package/lib/test/node.test.js +7 -4
- package/lib/version.js +1 -1
- package/package.json +36 -40
- package/src/dragAndDropHandler.ts +24 -10
- package/src/elementsRenderer.ts +49 -42
- package/src/jqtreeOptions.ts +3 -3
- package/src/mouse.widget.ts +12 -0
- package/src/node.ts +10 -5
- package/src/nodeElement.ts +27 -21
- package/src/saveStateHandler.ts +1 -1
- package/src/scrollHandler.ts +6 -2
- package/src/selectNodeHandler.ts +1 -1
- package/src/simple.widget.ts +2 -0
- package/src/test/jqTree/accessibility.test.ts +25 -0
- package/src/test/jqTree/events.test.ts +79 -93
- package/src/test/jqTree/methods.test.ts +1 -1
- package/src/test/node.test.ts +6 -4
- package/src/test/nodeUtil.test.ts +1 -1
- package/src/tree.jquery.ts +1 -1
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +100 -54
- package/tree.jquery.debug.js.map +1 -1
- package/tree.jquery.js +3 -3
- package/tree.jquery.js.map +1 -1
- package/tsconfig.json +1 -0
- package/.tool-versions +0 -1
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.svg +0 -3717
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.svg +0 -801
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.svg +0 -5028
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
package/lib/nodeElement.js
CHANGED
|
@@ -57,9 +57,9 @@ var NodeElement = /*#__PURE__*/function () {
|
|
|
57
57
|
var _this$treeWidget$opti;
|
|
58
58
|
var $li = this.getLi();
|
|
59
59
|
$li.addClass("jqtree-selected");
|
|
60
|
-
$li.attr("aria-selected", "true");
|
|
61
60
|
var $span = this.getSpan();
|
|
62
61
|
$span.attr("tabindex", (_this$treeWidget$opti = this.treeWidget.options.tabIndex) !== null && _this$treeWidget$opti !== void 0 ? _this$treeWidget$opti : null);
|
|
62
|
+
$span.attr("aria-selected", "true");
|
|
63
63
|
if (mustSetFocus) {
|
|
64
64
|
$span.trigger("focus");
|
|
65
65
|
}
|
|
@@ -69,10 +69,10 @@ var NodeElement = /*#__PURE__*/function () {
|
|
|
69
69
|
value: function deselect() {
|
|
70
70
|
var $li = this.getLi();
|
|
71
71
|
$li.removeClass("jqtree-selected");
|
|
72
|
-
$li.attr("aria-selected", "false");
|
|
73
72
|
var $span = this.getSpan();
|
|
74
73
|
$span.removeAttr("tabindex");
|
|
75
|
-
$span.
|
|
74
|
+
$span.attr("aria-selected", "false");
|
|
75
|
+
$span.trigger("blur");
|
|
76
76
|
}
|
|
77
77
|
}, {
|
|
78
78
|
key: "getUl",
|
|
@@ -120,14 +120,17 @@ var FolderElement = /*#__PURE__*/function (_NodeElement) {
|
|
|
120
120
|
$button.html("");
|
|
121
121
|
var buttonEl = $button.get(0);
|
|
122
122
|
if (buttonEl) {
|
|
123
|
-
var
|
|
124
|
-
|
|
123
|
+
var openedIconElement = this.treeWidget.renderer.openedIconElement;
|
|
124
|
+
if (openedIconElement) {
|
|
125
|
+
var icon = openedIconElement.cloneNode(true);
|
|
126
|
+
buttonEl.appendChild(icon);
|
|
127
|
+
}
|
|
125
128
|
}
|
|
126
129
|
var doOpen = function doOpen() {
|
|
127
130
|
var $li = _this.getLi();
|
|
128
131
|
$li.removeClass("jqtree-closed");
|
|
129
|
-
var $
|
|
130
|
-
$
|
|
132
|
+
var $titleSpan = _this.getSpan();
|
|
133
|
+
$titleSpan.attr("aria-expanded", "true");
|
|
131
134
|
if (onFinished) {
|
|
132
135
|
onFinished(_this.node);
|
|
133
136
|
}
|
|
@@ -157,14 +160,17 @@ var FolderElement = /*#__PURE__*/function (_NodeElement) {
|
|
|
157
160
|
$button.html("");
|
|
158
161
|
var buttonEl = $button.get(0);
|
|
159
162
|
if (buttonEl) {
|
|
160
|
-
var
|
|
161
|
-
|
|
163
|
+
var closedIconElement = this.treeWidget.renderer.closedIconElement;
|
|
164
|
+
if (closedIconElement) {
|
|
165
|
+
var icon = closedIconElement.cloneNode(true);
|
|
166
|
+
buttonEl.appendChild(icon);
|
|
167
|
+
}
|
|
162
168
|
}
|
|
163
169
|
var doClose = function doClose() {
|
|
164
170
|
var $li = _this2.getLi();
|
|
165
171
|
$li.addClass("jqtree-closed");
|
|
166
|
-
var $
|
|
167
|
-
$
|
|
172
|
+
var $titleSpan = _this2.getSpan();
|
|
173
|
+
$titleSpan.attr("aria-expanded", "false");
|
|
168
174
|
_this2.treeWidget._triggerEvent("tree.close", {
|
|
169
175
|
node: _this2.node
|
|
170
176
|
});
|
|
@@ -254,7 +260,8 @@ var GhostDropHint = /*#__PURE__*/function () {
|
|
|
254
260
|
}, {
|
|
255
261
|
key: "moveInsideOpenFolder",
|
|
256
262
|
value: function moveInsideOpenFolder() {
|
|
257
|
-
var
|
|
263
|
+
var _this$node$children$;
|
|
264
|
+
var childElement = (_this$node$children$ = this.node.children[0]) === null || _this$node$children$ === void 0 ? void 0 : _this$node$children$.element;
|
|
258
265
|
if (childElement) {
|
|
259
266
|
jQuery(childElement).before(this.$ghost);
|
|
260
267
|
}
|
package/lib/saveStateHandler.js
CHANGED
|
@@ -107,7 +107,7 @@ var SaveStateHandler = /*#__PURE__*/function () {
|
|
|
107
107
|
value: function getNodeIdToBeSelected() {
|
|
108
108
|
var state = this.getStateFromStorage();
|
|
109
109
|
if (state && state.selected_node) {
|
|
110
|
-
return state.selected_node[0];
|
|
110
|
+
return state.selected_node[0] || null;
|
|
111
111
|
} else {
|
|
112
112
|
return null;
|
|
113
113
|
}
|
package/lib/scrollHandler.js
CHANGED
|
@@ -37,7 +37,7 @@ var ScrollHandler = /*#__PURE__*/function () {
|
|
|
37
37
|
key: "scrollToY",
|
|
38
38
|
value: function scrollToY(top) {
|
|
39
39
|
this.ensureInit();
|
|
40
|
-
if (this.$scrollParent) {
|
|
40
|
+
if (this.$scrollParent && this.$scrollParent[0]) {
|
|
41
41
|
this.$scrollParent[0].scrollTop = top;
|
|
42
42
|
} else {
|
|
43
43
|
var offset = this.treeWidget.$el.offset();
|
|
@@ -83,7 +83,8 @@ var ScrollHandler = /*#__PURE__*/function () {
|
|
|
83
83
|
}, {
|
|
84
84
|
key: "initScrollParent",
|
|
85
85
|
value: function initScrollParent() {
|
|
86
|
-
var _this = this
|
|
86
|
+
var _this = this,
|
|
87
|
+
_$scrollParent$;
|
|
87
88
|
var getParentWithOverflow = function getParentWithOverflow() {
|
|
88
89
|
var cssAttributes = ["overflow", "overflow-y"];
|
|
89
90
|
var hasOverFlow = function hasOverFlow($el) {
|
|
@@ -124,7 +125,7 @@ var ScrollHandler = /*#__PURE__*/function () {
|
|
|
124
125
|
setDocumentAsScrollParent();
|
|
125
126
|
}
|
|
126
127
|
var $scrollParent = getParentWithOverflow();
|
|
127
|
-
if ($scrollParent && $scrollParent.length && $scrollParent[0]
|
|
128
|
+
if ($scrollParent && $scrollParent.length && ((_$scrollParent$ = $scrollParent[0]) === null || _$scrollParent$ === void 0 ? void 0 : _$scrollParent$.tagName) !== "HTML") {
|
|
128
129
|
this.$scrollParent = $scrollParent;
|
|
129
130
|
var offset = this.$scrollParent.offset();
|
|
130
131
|
this.scrollParentTop = offset ? offset.top : 0;
|
|
@@ -210,6 +211,9 @@ var ScrollHandler = /*#__PURE__*/function () {
|
|
|
210
211
|
return;
|
|
211
212
|
}
|
|
212
213
|
var scrollParent = $scrollParent[0];
|
|
214
|
+
if (!scrollParent) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
213
217
|
var canScrollRight = scrollParent.scrollLeft + scrollParent.clientWidth < scrollParent.scrollWidth;
|
|
214
218
|
var canScrollLeft = scrollParent.scrollLeft > 0;
|
|
215
219
|
var rightEdge = scrollParentOffset.left + scrollParent.clientWidth;
|
package/lib/selectNodeHandler.js
CHANGED
|
@@ -26,7 +26,7 @@ var SelectNodeHandler = /*#__PURE__*/function () {
|
|
|
26
26
|
value: function getSelectedNode() {
|
|
27
27
|
var selectedNodes = this.getSelectedNodes();
|
|
28
28
|
if (selectedNodes.length) {
|
|
29
|
-
return selectedNodes[0];
|
|
29
|
+
return selectedNodes[0] || false;
|
|
30
30
|
} else {
|
|
31
31
|
return false;
|
|
32
32
|
}
|
package/lib/simple.widget.js
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
var _jestAxe = require("jest-axe");
|
|
5
|
+
require("../../tree.jquery");
|
|
6
|
+
var _exampleData = _interopRequireDefault(require("../support/exampleData"));
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
+
expect.extend(_jestAxe.toHaveNoViolations);
|
|
12
|
+
beforeEach(function () {
|
|
13
|
+
$("body").append('<div id="tree1"></div>');
|
|
14
|
+
});
|
|
15
|
+
afterEach(function () {
|
|
16
|
+
var $tree = $("#tree1");
|
|
17
|
+
$tree.tree("destroy");
|
|
18
|
+
$tree.remove();
|
|
19
|
+
});
|
|
20
|
+
it("has an accessible ui", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
21
|
+
var $tree, element;
|
|
22
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
23
|
+
while (1) switch (_context.prev = _context.next) {
|
|
24
|
+
case 0:
|
|
25
|
+
$tree = $("#tree1");
|
|
26
|
+
$tree.tree({
|
|
27
|
+
data: _exampleData["default"]
|
|
28
|
+
});
|
|
29
|
+
element = $tree.get()[0];
|
|
30
|
+
_context.next = 5;
|
|
31
|
+
return expect((0, _jestAxe.axe)(element)).resolves.toHaveNoViolations();
|
|
32
|
+
case 5:
|
|
33
|
+
case "end":
|
|
34
|
+
return _context.stop();
|
|
35
|
+
}
|
|
36
|
+
}, _callee);
|
|
37
|
+
})));
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
4
|
var _givens = _interopRequireDefault(require("givens"));
|
|
4
5
|
var _msw = require("msw");
|
|
5
6
|
var _node = require("msw/node");
|
|
7
|
+
var _dom = require("@testing-library/dom");
|
|
6
8
|
require("../../tree.jquery");
|
|
7
9
|
var _exampleData = _interopRequireDefault(require("../support/exampleData"));
|
|
8
10
|
var _testUtil = require("../support/testUtil");
|
|
9
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
13
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
14
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
15
|
var context = describe;
|
|
11
16
|
var server = (0, _node.setupServer)();
|
|
12
17
|
beforeAll(function () {
|
|
@@ -41,14 +46,12 @@ describe("tree.click", function () {
|
|
|
41
46
|
});
|
|
42
47
|
});
|
|
43
48
|
it("fires tree.click", function () {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
given.titleSpan.trigger("click");
|
|
51
|
-
});
|
|
49
|
+
var onClick = jest.fn();
|
|
50
|
+
given.$tree.on("tree.click", onClick);
|
|
51
|
+
given.titleSpan.trigger("click");
|
|
52
|
+
expect(onClick).toHaveBeenCalledWith(expect.objectContaining({
|
|
53
|
+
node: given.node1
|
|
54
|
+
}));
|
|
52
55
|
});
|
|
53
56
|
});
|
|
54
57
|
describe("tree.contextmenu", function () {
|
|
@@ -68,14 +71,12 @@ describe("tree.contextmenu", function () {
|
|
|
68
71
|
});
|
|
69
72
|
});
|
|
70
73
|
it("fires tree.contextmenu", function () {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
given.titleSpan.contextmenu();
|
|
78
|
-
});
|
|
74
|
+
var onContextMenu = jest.fn();
|
|
75
|
+
given.$tree.on("tree.contextmenu", onContextMenu);
|
|
76
|
+
given.titleSpan.trigger("contextmenu");
|
|
77
|
+
expect(onContextMenu).toHaveBeenCalledWith(expect.objectContaining({
|
|
78
|
+
node: given.node1
|
|
79
|
+
}));
|
|
79
80
|
});
|
|
80
81
|
});
|
|
81
82
|
describe("tree.dblclick", function () {
|
|
@@ -95,14 +96,12 @@ describe("tree.dblclick", function () {
|
|
|
95
96
|
});
|
|
96
97
|
});
|
|
97
98
|
it("fires tree.dblclick", function () {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
given.titleSpan.trigger("dblclick");
|
|
105
|
-
});
|
|
99
|
+
var onDoubleClick = jest.fn();
|
|
100
|
+
given.$tree.on("tree.dblclick", onDoubleClick);
|
|
101
|
+
given.titleSpan.trigger("dblclick");
|
|
102
|
+
expect(onDoubleClick).toHaveBeenCalledWith(expect.objectContaining({
|
|
103
|
+
node: given.node1
|
|
104
|
+
}));
|
|
106
105
|
});
|
|
107
106
|
});
|
|
108
107
|
describe("tree.init", function () {
|
|
@@ -112,18 +111,14 @@ describe("tree.init", function () {
|
|
|
112
111
|
});
|
|
113
112
|
context("with json data", function () {
|
|
114
113
|
it("is called", function () {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
name: "node2"
|
|
120
|
-
});
|
|
121
|
-
done();
|
|
122
|
-
});
|
|
123
|
-
given.$tree.tree({
|
|
124
|
-
data: _exampleData["default"]
|
|
125
|
-
});
|
|
114
|
+
var onInit = jest.fn();
|
|
115
|
+
given.$tree.on("tree.init", onInit);
|
|
116
|
+
given.$tree.tree({
|
|
117
|
+
data: _exampleData["default"]
|
|
126
118
|
});
|
|
119
|
+
|
|
120
|
+
// eslint-disable-next-line jest/prefer-called-with
|
|
121
|
+
expect(onInit).toHaveBeenCalled();
|
|
127
122
|
});
|
|
128
123
|
});
|
|
129
124
|
context("with data loaded from an url", function () {
|
|
@@ -132,20 +127,27 @@ describe("tree.init", function () {
|
|
|
132
127
|
return response(ctx.status(200), ctx.json(_exampleData["default"]));
|
|
133
128
|
}));
|
|
134
129
|
});
|
|
135
|
-
it("is called", function () {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
130
|
+
it("is called", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
131
|
+
var onInit;
|
|
132
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
133
|
+
while (1) switch (_context.prev = _context.next) {
|
|
134
|
+
case 0:
|
|
135
|
+
onInit = jest.fn();
|
|
136
|
+
given.$tree.on("tree.init", onInit);
|
|
137
|
+
given.$tree.tree({
|
|
138
|
+
dataUrl: "/tree/"
|
|
139
|
+
});
|
|
140
|
+
_context.next = 5;
|
|
141
|
+
return (0, _dom.waitFor)(function () {
|
|
142
|
+
// eslint-disable-next-line jest/prefer-called-with
|
|
143
|
+
expect(onInit).toHaveBeenCalled();
|
|
144
|
+
});
|
|
145
|
+
case 5:
|
|
146
|
+
case "end":
|
|
147
|
+
return _context.stop();
|
|
148
|
+
}
|
|
149
|
+
}, _callee);
|
|
150
|
+
})));
|
|
149
151
|
});
|
|
150
152
|
});
|
|
151
153
|
describe("tree.load_data", function () {
|
|
@@ -155,16 +157,14 @@ describe("tree.load_data", function () {
|
|
|
155
157
|
});
|
|
156
158
|
context("when the tree is initialized with data", function () {
|
|
157
159
|
it("fires tree.load_data", function () {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
resolve();
|
|
163
|
-
});
|
|
164
|
-
given.$tree.tree({
|
|
165
|
-
data: _exampleData["default"]
|
|
166
|
-
});
|
|
160
|
+
var onLoadData = jest.fn();
|
|
161
|
+
given.$tree.on("tree.load_data", onLoadData);
|
|
162
|
+
given.$tree.tree({
|
|
163
|
+
data: _exampleData["default"]
|
|
167
164
|
});
|
|
165
|
+
expect(onLoadData).toHaveBeenCalledWith(expect.objectContaining({
|
|
166
|
+
tree_data: _exampleData["default"]
|
|
167
|
+
}));
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
170
|
});
|
|
@@ -184,31 +184,27 @@ describe("tree.select", function () {
|
|
|
184
184
|
data: _exampleData["default"]
|
|
185
185
|
});
|
|
186
186
|
});
|
|
187
|
-
it("fires tree.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
given.titleSpan.trigger("click");
|
|
196
|
-
});
|
|
187
|
+
it("fires tree.select", function () {
|
|
188
|
+
var onSelect = jest.fn();
|
|
189
|
+
given.$tree.on("tree.select", onSelect);
|
|
190
|
+
given.titleSpan.trigger("click");
|
|
191
|
+
expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({
|
|
192
|
+
node: given.node1,
|
|
193
|
+
deselected_node: null
|
|
194
|
+
}));
|
|
197
195
|
});
|
|
198
196
|
context("when the node was selected", function () {
|
|
199
197
|
beforeEach(function () {
|
|
200
198
|
given.$tree.tree("selectNode", given.node1);
|
|
201
199
|
});
|
|
202
200
|
it("fires tree.select with node is null", function () {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
given.titleSpan.trigger("click");
|
|
211
|
-
});
|
|
201
|
+
var onSelect = jest.fn();
|
|
202
|
+
given.$tree.on("tree.select", onSelect);
|
|
203
|
+
given.titleSpan.trigger("click");
|
|
204
|
+
expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({
|
|
205
|
+
node: null,
|
|
206
|
+
previous_node: given.node1
|
|
207
|
+
}));
|
|
212
208
|
});
|
|
213
209
|
});
|
|
214
210
|
});
|
package/lib/test/node.test.js
CHANGED
|
@@ -151,7 +151,8 @@ describe("addChild", function () {
|
|
|
151
151
|
})]));
|
|
152
152
|
});
|
|
153
153
|
it("sets the parent of the child", function () {
|
|
154
|
-
|
|
154
|
+
var _given$node$children$;
|
|
155
|
+
expect((_given$node$children$ = given.node.children[0]) === null || _given$node$children$ === void 0 ? void 0 : _given$node$children$.parent).toEqual(given.node);
|
|
155
156
|
});
|
|
156
157
|
});
|
|
157
158
|
describe("addChildAtPosition", function () {
|
|
@@ -486,13 +487,15 @@ describe("getLastChild", function () {
|
|
|
486
487
|
context("when its last child is open and has children", function () {
|
|
487
488
|
beforeEach(function () {
|
|
488
489
|
var child2 = given.node.children[1];
|
|
489
|
-
child2.append("child2a");
|
|
490
|
-
child2.append("child2b");
|
|
490
|
+
child2 === null || child2 === void 0 ? void 0 : child2.append("child2a");
|
|
491
|
+
child2 === null || child2 === void 0 ? void 0 : child2.append("child2b");
|
|
491
492
|
});
|
|
492
493
|
context("and the last child is open", function () {
|
|
493
494
|
beforeEach(function () {
|
|
494
495
|
var child2 = given.node.children[1];
|
|
495
|
-
child2
|
|
496
|
+
if (child2) {
|
|
497
|
+
child2.is_open = true;
|
|
498
|
+
}
|
|
496
499
|
});
|
|
497
500
|
it("returns the last child of that child", function () {
|
|
498
501
|
expect(given.node.getLastChild()).toMatchObject({
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jqtree",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Tree widget for jQuery",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jquery-plugin",
|
|
@@ -23,60 +23,56 @@
|
|
|
23
23
|
"devserver-with-coverage": "COVERAGE=true SERVE=true rollup --config config/rollup.config.mjs",
|
|
24
24
|
"build-with-coverage": "COVERAGE=true rollup --config config/rollup.config.mjs",
|
|
25
25
|
"prettier": "prettier src/*.ts --write --tab-width 4",
|
|
26
|
-
"write-coverage": "nyc report --reporter=text-lcov > lcov.info",
|
|
27
26
|
"tsc": "tsc --noEmit --project tsconfig.json",
|
|
28
|
-
"merge-coverage": "cp jest-coverage/coverage-final.json .nyc_output/coverage_jsdom.json",
|
|
29
|
-
"clean-coverage": "rm -rf .nyc_output && jest --clearCache",
|
|
30
|
-
"print-coverage": "nyc report",
|
|
31
27
|
"playwright": "pnpm build-with-coverage && playwright test --config config/playwright.config.js",
|
|
32
28
|
"test": "pnpm jest && pnpm playwright"
|
|
33
29
|
},
|
|
34
30
|
"dependencies": {
|
|
35
|
-
"jquery": "^3.
|
|
31
|
+
"jquery": "^3.7.0"
|
|
36
32
|
},
|
|
37
33
|
"devDependencies": {
|
|
38
|
-
"@babel/cli": "^7.
|
|
39
|
-
"@babel/core": "^7.
|
|
40
|
-
"@babel/preset-env": "^7.
|
|
41
|
-
"@babel/preset-typescript": "^7.
|
|
42
|
-
"@playwright/test": "^1.
|
|
34
|
+
"@babel/cli": "^7.22.9",
|
|
35
|
+
"@babel/core": "^7.22.9",
|
|
36
|
+
"@babel/preset-env": "^7.22.9",
|
|
37
|
+
"@babel/preset-typescript": "^7.22.5",
|
|
38
|
+
"@playwright/test": "^1.36.2",
|
|
43
39
|
"@rollup/plugin-babel": "^6.0.3",
|
|
44
|
-
"@rollup/plugin-node-resolve": "^15.0
|
|
45
|
-
"@rollup/plugin-terser": "^0.
|
|
46
|
-
"@testing-library/dom": "^
|
|
47
|
-
"@types/debug": "^4.1.
|
|
48
|
-
"@types/jest": "^29.
|
|
49
|
-
"@types/
|
|
50
|
-
"@types/
|
|
51
|
-
"@
|
|
52
|
-
"@typescript-eslint/
|
|
53
|
-
"
|
|
54
|
-
"
|
|
40
|
+
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
41
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
42
|
+
"@testing-library/dom": "^9.3.1",
|
|
43
|
+
"@types/debug": "^4.1.8",
|
|
44
|
+
"@types/jest": "^29.5.3",
|
|
45
|
+
"@types/jest-axe": "^3.5.5",
|
|
46
|
+
"@types/jquery": "^3.5.16",
|
|
47
|
+
"@types/node": "^20.4.7",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^6.2.1",
|
|
49
|
+
"@typescript-eslint/parser": "^6.2.1",
|
|
50
|
+
"autoprefixer": "^10.4.14",
|
|
51
|
+
"babel-jest": "^29.6.2",
|
|
55
52
|
"babel-plugin-istanbul": "^6.1.1",
|
|
56
|
-
"eslint": "^8.
|
|
57
|
-
"eslint-plugin-import": "^2.
|
|
58
|
-
"eslint-plugin-jest": "^27.
|
|
59
|
-
"eslint-plugin-playwright": "^0.
|
|
60
|
-
"eslint-plugin-testing-library": "^5.
|
|
53
|
+
"eslint": "^8.46.0",
|
|
54
|
+
"eslint-plugin-import": "^2.28.0",
|
|
55
|
+
"eslint-plugin-jest": "^27.2.3",
|
|
56
|
+
"eslint-plugin-playwright": "^0.15.3",
|
|
57
|
+
"eslint-plugin-testing-library": "^5.11.0",
|
|
61
58
|
"givens": "^1.3.9",
|
|
62
|
-
"graphql": "^16.
|
|
63
|
-
"jest": "^29.
|
|
64
|
-
"jest-
|
|
65
|
-
"jest-
|
|
59
|
+
"graphql": "^16.7.1",
|
|
60
|
+
"jest": "^29.6.2",
|
|
61
|
+
"jest-axe": "^8.0.0",
|
|
62
|
+
"jest-environment-jsdom": "^29.6.2",
|
|
63
|
+
"jest-extended": "^4.0.1",
|
|
66
64
|
"jsonfile": "^6.1.0",
|
|
67
65
|
"lodash.template": "^4.5.0",
|
|
68
|
-
"msw": "^
|
|
69
|
-
"
|
|
70
|
-
"playwright": "^1.29.1",
|
|
71
|
-
"postcss": "^8.4.20",
|
|
66
|
+
"msw": "^1.2.3",
|
|
67
|
+
"postcss": "^8.4.27",
|
|
72
68
|
"postcss-cli": "^10.1.0",
|
|
73
69
|
"postcss-import": "^15.1.0",
|
|
74
70
|
"postcss-load-config": "^4.0.1",
|
|
75
|
-
"postcss-nested": "^6.0.
|
|
76
|
-
"prettier": "^
|
|
77
|
-
"rollup": "^3.
|
|
71
|
+
"postcss-nested": "^6.0.1",
|
|
72
|
+
"prettier": "^3.0.1",
|
|
73
|
+
"rollup": "^3.27.2",
|
|
78
74
|
"rollup-plugin-serve": "^2.0.2",
|
|
79
|
-
"tslib": "^2.
|
|
80
|
-
"typescript": "~
|
|
75
|
+
"tslib": "^2.6.1",
|
|
76
|
+
"typescript": "~5.1.6"
|
|
81
77
|
}
|
|
82
78
|
}
|