Release 2.8.6
This commit is contained in:
@@ -886,7 +886,7 @@
|
||||
var summaryLabel = isRoot ? (isArray ? 'Array' : 'Object') : String(key);
|
||||
var summaryMeta = isArray ? '[' + value.length + ']' : '{' + Object.keys(value).length + '}';
|
||||
return '' +
|
||||
'<details class="json-tree-node" open>' +
|
||||
'<details class="json-tree-node"' + (isRoot ? ' open' : '') + '>' +
|
||||
'<summary><span class="json-tree-key">' + escapeHtml(summaryLabel) + '</span><span class="mx-1">:</span><span class="text-body-secondary">' + escapeHtml(summaryMeta) + '</span></summary>' +
|
||||
'<div class="ms-3 ps-3 border-start">' + entries + '</div>' +
|
||||
'</details>';
|
||||
@@ -945,26 +945,30 @@
|
||||
detail.open = expanded;
|
||||
});
|
||||
|
||||
if (collapseButton) {
|
||||
collapseButton.disabled = !details.length || !expanded;
|
||||
}
|
||||
if (expandButton) {
|
||||
expandButton.disabled = !details.length || expanded;
|
||||
}
|
||||
syncButtons();
|
||||
}
|
||||
|
||||
function syncButtons() {
|
||||
var details = output.querySelectorAll('details');
|
||||
var allExpanded = details.length > 0 && Array.prototype.every.call(details, function (detail) { return detail.open; });
|
||||
var allCollapsed = details.length > 0 && Array.prototype.every.call(details, function (detail) { return !detail.open; });
|
||||
if (collapseButton) {
|
||||
collapseButton.setAttribute('aria-pressed', 'false');
|
||||
collapseButton.disabled = !details.length || allCollapsed;
|
||||
collapseButton.setAttribute('aria-pressed', String(allCollapsed));
|
||||
}
|
||||
if (expandButton) {
|
||||
expandButton.setAttribute('aria-pressed', 'true');
|
||||
expandButton.disabled = !details.length || allExpanded;
|
||||
expandButton.setAttribute('aria-pressed', String(allExpanded));
|
||||
}
|
||||
}
|
||||
|
||||
output.innerHTML = formattedTree;
|
||||
setAllSectionsExpanded(false);
|
||||
var rootDetails = output.querySelector('details');
|
||||
if (rootDetails) {
|
||||
rootDetails.open = true;
|
||||
}
|
||||
syncButtons();
|
||||
setAllSectionsExpanded(true);
|
||||
|
||||
if (collapseButton) {
|
||||
collapseButton.addEventListener('click', function () {
|
||||
|
||||
Reference in New Issue
Block a user