MCPcopy Create free account
hub / github.com/andreadev-it/stacking-contexts-inspector / generateContextTree

Function generateContextTree

src/scripts/utils/utils.js:7–22  ·  view source on GitHub ↗
(contextsList)

Source from the content-addressed store, hash-verified

5 * @returns {Object} A representation of a stacking context adapted for the devtools scripts.
6 */
7export function generateContextTree(contextsList) {
8 let root = contextsList[0];
9
10 function linkChildren(context) {
11 // Get a context from its id (since the ids start from 0, the id is also its index inside the array)
12 context.children = context.children.map( (child) => contextsList[child] );
13 for (let child of context.children) {
14 child.parent = context;
15 linkChildren(child);
16 }
17 }
18
19 linkChildren(root);
20
21 return root;
22}
23
24export function isValuableContainer(container) {
25 // Check if has children

Callers 1

setContextsFunction · 0.90

Calls 1

linkChildrenFunction · 0.85

Tested by

no test coverage detected