MCPcopy
hub / github.com/markmap/markmap / childSelector

Function childSelector

packages/markmap-view/src/util.ts:74–87  ·  view source on GitHub ↗
(
  filter?: string | ((el: T) => boolean),
)

Source from the content-addressed store, hash-verified

72}
73
74export function childSelector<T extends Element>(
75 filter?: string | ((el: T) => boolean),
76): () => T[] {
77 if (typeof filter === 'string') {
78 const selector = filter;
79 filter = (el: T): boolean => el.matches(selector);
80 }
81 const filterFn = filter;
82 return function selector(this: Element): T[] {
83 let nodes = Array.from(this.childNodes as NodeListOf<T>);
84 if (filterFn) nodes = nodes.filter((node) => filterFn(node));
85 return nodes;
86 };
87}

Callers 3

_relayoutMethod · 0.90
renderDataMethod · 0.90
findElementMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected