@enotes/groot
Advanced tools
Comparing version 1.0.7-beta to 1.1.0
{ | ||
"name": "@enotes/groot", | ||
"description": "Groot, a content tree.", | ||
"version": "1.0.7-beta", | ||
"version": "1.1.0", | ||
"main": "src/groot.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -177,2 +177,27 @@ 'use strict'; | ||
/** | ||
* Gets a collection of this leaf's ancestors, starting | ||
* with the closest ancestor and ending with the furthest. | ||
* If inverse=true, then the order will be reversed. | ||
* @param {Boolean} inverse - inverse the order of ancestors | ||
* @return {Array.<Leaf>} | ||
*/ | ||
getAncestors: function (inverse = false) { | ||
const ancestors = []; | ||
let leaf = this, | ||
parent = leaf.getParent(); | ||
while (parent) { | ||
if (inverse) { | ||
// furthest to closest | ||
ancestors.unshift(parent); | ||
} else { | ||
// closest to furthest | ||
ancestors.push(parent); | ||
} | ||
leaf = parent; | ||
parent = leaf.getParent(); | ||
} | ||
return ancestors; | ||
}, | ||
/** | ||
* Does this instance have any children? | ||
@@ -179,0 +204,0 @@ * @returns {Boolean} |
@@ -368,3 +368,14 @@ 'use strict'; | ||
const listItem = this._findListItem(sourceLeaf); | ||
// recursively render ancestors that have not yet | ||
// been rendered | ||
const ancestorLeafs = sourceLeaf.getAncestors(true); | ||
while (ancestorLeafs.length) { | ||
const ancestorLeaf = ancestorLeafs.shift(); | ||
if (ancestorLeaf.isExpanded) { | ||
continue; | ||
} | ||
ancestorLeaf.toggle(); | ||
const ancestorListItem = this._findListItem(ancestorLeaf); | ||
this._renderLeaf(ancestorListItem, ancestorLeaf); | ||
} | ||
@@ -382,2 +393,3 @@ const EXPAND_ARGS = { | ||
const listItem = this._findListItem(sourceLeaf); | ||
this._renderLeaf(listItem, sourceLeaf); | ||
@@ -384,0 +396,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2540673
25680
0
1