@oscarpalmer/atoms 0.30.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,32 +8,27 @@ var _findElements = function(selector, context, single) {
8
8
  let index2 = 0;
9
9
  for (;index2 < length2; index2 += 1) {
10
10
  const value = callback.call(contexts[index2], selector);
11
- if (single && value != null) {
11
+ if (single) {
12
+ if (value == null) {
13
+ continue;
14
+ }
12
15
  return value;
13
16
  }
14
- if (!single) {
15
- result.push(...Array.from(value));
16
- }
17
+ result.push(...Array.from(value));
17
18
  }
18
19
  return single ? undefined : result.filter((value, index3, array) => array.indexOf(value) === index3);
19
20
  }
20
- const nodes = Array.isArray(selector) || selector instanceof NodeList ? selector : [selector];
21
+ const nodes = Array.isArray(selector) ? selector : selector instanceof NodeList ? Array.from(selector) : [selector];
21
22
  const { length } = nodes;
22
23
  let index = 0;
23
24
  for (;index < length; index += 1) {
24
25
  const node = nodes[index];
25
26
  const element = node instanceof Document ? node.body : node instanceof Element ? node : undefined;
26
- if (element == null) {
27
- continue;
28
- }
29
- if (context == null || contexts.some((context2) => context2.contains(node))) {
30
- if (single) {
31
- return element;
32
- }
27
+ if (element != null && (context == null || contexts.length === 0 || contexts.some((context2) => context2 === element || context2.contains(element))) && !result.includes(element)) {
33
28
  result.push(element);
34
29
  }
35
30
  }
36
- return single ? undefined : result.filter((value, index2, array) => array.indexOf(value) === index2);
31
+ return result;
37
32
  };
38
33
  function findElement(selector, context) {
39
34
  return _findElements(selector, context, true);
@@ -66,7 +61,7 @@ function getElementUnderPointer(skipIgnore) {
66
61
  return false;
67
62
  }
68
63
  const style = getComputedStyle(element);
69
- return typeof skipIgnore === "boolean" && skipIgnore || style.pointerEvents !== "none" && style.visibility !== "hidden";
64
+ return skipIgnore === true || style.pointerEvents !== "none" && style.visibility !== "hidden";
70
65
  });
71
66
  return elements[elements.length - 1];
72
67
  }
@@ -8,32 +8,27 @@ var _findElements = function(selector, context, single) {
8
8
  let index2 = 0;
9
9
  for (;index2 < length2; index2 += 1) {
10
10
  const value = callback.call(contexts[index2], selector);
11
- if (single && value != null) {
11
+ if (single) {
12
+ if (value == null) {
13
+ continue;
14
+ }
12
15
  return value;
13
16
  }
14
- if (!single) {
15
- result.push(...Array.from(value));
16
- }
17
+ result.push(...Array.from(value));
17
18
  }
18
19
  return single ? undefined : result.filter((value, index3, array) => array.indexOf(value) === index3);
19
20
  }
20
- const nodes = Array.isArray(selector) || selector instanceof NodeList ? selector : [selector];
21
+ const nodes = Array.isArray(selector) ? selector : selector instanceof NodeList ? Array.from(selector) : [selector];
21
22
  const { length } = nodes;
22
23
  let index = 0;
23
24
  for (;index < length; index += 1) {
24
25
  const node = nodes[index];
25
26
  const element = node instanceof Document ? node.body : node instanceof Element ? node : undefined;
26
- if (element == null) {
27
- continue;
28
- }
29
- if (context == null || contexts.some((context2) => context2.contains(node))) {
30
- if (single) {
31
- return element;
32
- }
27
+ if (element != null && (context == null || contexts.length === 0 || contexts.some((context2) => context2 === element || context2.contains(element))) && !result.includes(element)) {
33
28
  result.push(element);
34
29
  }
35
30
  }
36
- return single ? undefined : result.filter((value, index2, array) => array.indexOf(value) === index2);
31
+ return result;
37
32
  };
38
33
  function findElement(selector, context) {
39
34
  return _findElements(selector, context, true);
@@ -66,7 +61,7 @@ function getElementUnderPointer(skipIgnore) {
66
61
  return false;
67
62
  }
68
63
  const style = getComputedStyle(element);
69
- return typeof skipIgnore === "boolean" && skipIgnore || style.pointerEvents !== "none" && style.visibility !== "hidden";
64
+ return skipIgnore === true || style.pointerEvents !== "none" && style.visibility !== "hidden";
70
65
  });
71
66
  return elements[elements.length - 1];
72
67
  }