MCPcopy Create free account
hub / github.com/bugy/script-server / findNeighbour

Function findNeighbour

web-src/src/common/utils/common.js:1–23  ·  view source on GitHub ↗
(element, tag)

Source from the content-addressed store, hash-verified

1export function findNeighbour(element, tag) {
2 var tagLower = tag.toLowerCase();
3
4 var previous = element.previousSibling;
5 while (!isNull(previous)) {
6 if (previous.tagName.toLowerCase() === tagLower) {
7 return previous;
8 }
9
10 previous = previous.previousSibling;
11 }
12
13 var next = element.nextSibling;
14 while (!isNull(next)) {
15 if (next.tagName.toLowerCase() === tagLower) {
16 return next;
17 }
18
19 next = next.nextSibling;
20 }
21
22 return null;
23}
24
25export function isEmptyString(value) {
26 return isNull(value) || ((typeof value === 'string') && (value.length === 0));

Callers

nothing calls this directly

Calls 1

isNullFunction · 0.85

Tested by

no test coverage detected