MCPcopy Index your code
hub / github.com/OneNoteDev/WebClipper / sortByDepth

Function sortByDepth

src/scripts/highlighting/textHighlighter.js:140–144  ·  view source on GitHub ↗

* Sorts array of DOM elements by its depth in DOM tree. * @param {HTMLElement[]} arr - array to sort. * @param {boolean} descending - order of sort.

(arr, descending)

Source from the content-addressed store, hash-verified

138 * @param {boolean} descending - order of sort.
139 */
140 function sortByDepth(arr, descending) {
141 arr.sort(function (a, b) {
142 return dom(descending ? b : a).parents().length - dom(descending ? a : b).parents().length;
143 });
144 }
145
146 /**
147 * Groups given highlights by timestamp.

Callers 1

textHighlighter.jsFile · 0.85

Calls 1

domFunction · 0.85

Tested by

no test coverage detected