Passed
Pull Request — master (#312)
by
unknown
03:23 queued 01:23
created

client/kit/src/lib/actions.ts   A

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 21
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 15
mnd 2
bc 2
fnc 2
dl 0
loc 21
bpm 1
cpm 2
noi 0
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A actions.ts ➔ destroy 0 2 2
1
export const clickOutside = (
2
  node: HTMLElement,
3
  callback: () => void
4
): {
5
  destroy: () => void;
6
} => {
7
  const handleClick = (event: Event) => {
8
    if (!node.contains(event.target as HTMLElement)) {
9
      callback();
10
    }
11
  };
12
13
  document.addEventListener("click", handleClick, true);
14
15
  return {
16
    destroy() {
17
      document.removeEventListener("click", handleClick, true);
18
    },
19
  };
20
};
21