Skip to content

Commit

Permalink
Build
Browse files Browse the repository at this point in the history
  • Loading branch information
mbraak committed Aug 5, 2023
1 parent 920a119 commit 83e0090
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 42 deletions.
26 changes: 14 additions & 12 deletions lib/elementsRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ var ElementsRenderer = /*#__PURE__*/function () {
}
}, {
key: "setTreeItemAriaAttributes",
value: function setTreeItemAriaAttributes(li, node, level, isSelected) {
li.setAttribute("aria-label", node.name);
li.setAttribute("aria-level", "".concat(level));
li.setAttribute("aria-selected", (0, _util.getBoolString)(isSelected));
li.setAttribute("role", "treeitem");
value: function setTreeItemAriaAttributes(element, name, level, isSelected) {
element.setAttribute("aria-label", name);
element.setAttribute("aria-level", "".concat(level));
element.setAttribute("aria-selected", (0, _util.getBoolString)(isSelected));
element.setAttribute("role", "treeitem");
}
}, {
key: "createFolderLi",
Expand All @@ -145,8 +145,7 @@ var ElementsRenderer = /*#__PURE__*/function () {
// li
var li = document.createElement("li");
li.className = "jqtree_common ".concat(folderClasses);
this.setTreeItemAriaAttributes(li, node, level, isSelected);
li.setAttribute("aria-expanded", (0, _util.getBoolString)(node.is_open));
li.setAttribute("role", "none");

// div
var div = document.createElement("div");
Expand All @@ -157,7 +156,6 @@ var ElementsRenderer = /*#__PURE__*/function () {
// button link
var buttonLink = document.createElement("a");
buttonLink.className = buttonClasses;
buttonLink.setAttribute("aria-hidden", "true");
if (iconElement) {
buttonLink.appendChild(iconElement.cloneNode(true));
}
Expand All @@ -166,7 +164,9 @@ var ElementsRenderer = /*#__PURE__*/function () {
}

// title span
div.appendChild(this.createTitleSpan(node.name, isSelected, true));
var titleSpan = this.createTitleSpan(node.name, isSelected, true, level);
titleSpan.setAttribute("aria-expanded", (0, _util.getBoolString)(node.is_open));
div.appendChild(titleSpan);
if (!this.treeWidget.options.buttonLeft) {
div.appendChild(buttonLink);
}
Expand All @@ -184,7 +184,7 @@ var ElementsRenderer = /*#__PURE__*/function () {
// li
var li = document.createElement("li");
li.className = classString;
this.setTreeItemAriaAttributes(li, node, level, isSelected);
li.setAttribute("role", "none");

// div
var div = document.createElement("div");
Expand All @@ -193,12 +193,13 @@ var ElementsRenderer = /*#__PURE__*/function () {
li.appendChild(div);

// title span
div.appendChild(this.createTitleSpan(node.name, isSelected, false));
var titleSpan = this.createTitleSpan(node.name, isSelected, false, level);
div.appendChild(titleSpan);
return li;
}
}, {
key: "createTitleSpan",
value: function createTitleSpan(nodeName, isSelected, isFolder) {
value: function createTitleSpan(nodeName, isSelected, isFolder, level) {
var titleSpan = document.createElement("span");
var classes = "jqtree-title jqtree_common";
if (isFolder) {
Expand All @@ -212,6 +213,7 @@ var ElementsRenderer = /*#__PURE__*/function () {
titleSpan.setAttribute("tabindex", "".concat(tabIndex));
}
}
this.setTreeItemAriaAttributes(titleSpan, nodeName, level, isSelected);
if (this.treeWidget.options.autoEscape) {
titleSpan.textContent = nodeName;
} else {
Expand Down
10 changes: 6 additions & 4 deletions lib/nodeElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ var NodeElement = /*#__PURE__*/function () {
var _this$treeWidget$opti;
var $li = this.getLi();
$li.addClass("jqtree-selected");
$li.attr("aria-selected", "true");
var $span = this.getSpan();
$span.attr("tabindex", (_this$treeWidget$opti = this.treeWidget.options.tabIndex) !== null && _this$treeWidget$opti !== void 0 ? _this$treeWidget$opti : null);
$span.attr("aria-selected", "true");
if (mustSetFocus) {
$span.trigger("focus");
}
Expand All @@ -69,9 +69,9 @@ var NodeElement = /*#__PURE__*/function () {
value: function deselect() {
var $li = this.getLi();
$li.removeClass("jqtree-selected");
$li.attr("aria-selected", "true");
var $span = this.getSpan();
$span.removeAttr("tabindex");
$span.attr("aria-selected", "false");
$span.trigger("blur");
}
}, {
Expand Down Expand Up @@ -129,7 +129,8 @@ var FolderElement = /*#__PURE__*/function (_NodeElement) {
var doOpen = function doOpen() {
var $li = _this.getLi();
$li.removeClass("jqtree-closed");
$li.attr("aria-expanded", "true");
var $titleSpan = _this.getSpan();
$titleSpan.attr("aria-expanded", "true");
if (onFinished) {
onFinished(_this.node);
}
Expand Down Expand Up @@ -168,7 +169,8 @@ var FolderElement = /*#__PURE__*/function (_NodeElement) {
var doClose = function doClose() {
var $li = _this2.getLi();
$li.addClass("jqtree-closed");
$li.attr("aria-expanded", "false");
var $titleSpan = _this2.getSpan();
$titleSpan.attr("aria-expanded", "false");
_this2.treeWidget._triggerEvent("tree.close", {
node: _this2.node
});
Expand Down
10 changes: 3 additions & 7 deletions lib/test/jqTree/accessibility.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 20 additions & 16 deletions tree.jquery.debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tree.jquery.debug.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tree.jquery.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tree.jquery.js.map

Large diffs are not rendered by default.

0 comments on commit 83e0090

Please sign in to comment.