@augment-vir/web 31.73.1 → 31.73.3

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.
@@ -13,15 +13,23 @@
13
13
  * @package [`@augment-vir/web`](https://www.npmjs.com/package/@augment-vir/web)
14
14
  */
15
15
  export function getNestedChildren(startingElement, depth) {
16
- return recursivelyGetNestedChildren(startingElement, depth ?? 0, 0);
16
+ return recursivelyGetNestedChildren({
17
+ startingElement,
18
+ maxDepth: depth ?? 0,
19
+ currentDepth: 0,
20
+ });
17
21
  }
18
- function recursivelyGetNestedChildren(startingElement, maxDepth, currentDepth) {
22
+ function recursivelyGetNestedChildren({ startingElement, maxDepth, currentDepth, }) {
19
23
  const children = getDirectChildren(startingElement);
20
24
  return children.flatMap((child) => {
21
25
  const nextDepth = currentDepth + 1;
22
26
  const nested = maxDepth && nextDepth >= maxDepth
23
27
  ? []
24
- : recursivelyGetNestedChildren(child, maxDepth, nextDepth);
28
+ : recursivelyGetNestedChildren({
29
+ startingElement: child,
30
+ maxDepth,
31
+ currentDepth: nextDepth,
32
+ });
25
33
  return [
26
34
  child,
27
35
  nested,
@@ -45,15 +53,23 @@ function recursivelyGetNestedChildren(startingElement, maxDepth, currentDepth) {
45
53
  export function getNestedChildrenTree(startingElement, depth) {
46
54
  return {
47
55
  element: startingElement,
48
- children: recursivelyGetNestedChildrenTree(startingElement, depth ?? 0, 0),
56
+ children: recursivelyGetNestedChildrenTree({
57
+ startingElement,
58
+ maxDepth: depth ?? 0,
59
+ currentDepth: 0,
60
+ }),
49
61
  };
50
62
  }
51
- function recursivelyGetNestedChildrenTree(startingElement, maxDepth, currentDepth) {
63
+ function recursivelyGetNestedChildrenTree({ startingElement, maxDepth, currentDepth, }) {
52
64
  return getDirectChildren(startingElement).map((child) => {
53
65
  const nextDepth = currentDepth + 1;
54
66
  const nested = maxDepth && nextDepth >= Math.abs(maxDepth)
55
67
  ? []
56
- : recursivelyGetNestedChildrenTree(child, maxDepth, nextDepth);
68
+ : recursivelyGetNestedChildrenTree({
69
+ startingElement: child,
70
+ maxDepth,
71
+ currentDepth: nextDepth,
72
+ });
57
73
  return {
58
74
  element: child,
59
75
  children: nested,
@@ -20,7 +20,12 @@ export function queryThroughShadow(element, rawQuery, options = {}) {
20
20
  const query = check.isString(rawQuery) ? rawQuery : rawQuery.tagName;
21
21
  const splitQuery = query.split(' ').filter(check.isTruthy);
22
22
  if (splitQuery.length > 1) {
23
- return handleNestedQueries(element, query, options, splitQuery);
23
+ return handleNestedQueries({
24
+ element,
25
+ originalQuery: query,
26
+ options,
27
+ queries: splitQuery,
28
+ });
24
29
  }
25
30
  else if ('shadowRoot' in element && element.shadowRoot) {
26
31
  return queryThroughShadow(element.shadowRoot, query, options);
@@ -57,7 +62,7 @@ function getShadowRootChildren(element) {
57
62
  .filter((child) => !!child.shadowRoot)
58
63
  .map((child) => child.shadowRoot);
59
64
  }
60
- function handleNestedQueries(element, originalQuery, options, queries) {
65
+ function handleNestedQueries({ element, originalQuery, options, queries, }) {
61
66
  const firstQuery = queries[0];
62
67
  /**
63
68
  * No way to intentionally trigger this edge case, we're just catching it here for type
@@ -74,12 +79,22 @@ function handleNestedQueries(element, originalQuery, options, queries) {
74
79
  else if (check.isArray(results)) {
75
80
  return results
76
81
  .flatMap((result) => {
77
- return handleNestedQueries(result, originalQuery, options, queries.slice(1));
82
+ return handleNestedQueries({
83
+ element: result,
84
+ originalQuery,
85
+ options,
86
+ queries: queries.slice(1),
87
+ });
78
88
  })
79
89
  .filter(check.isTruthy);
80
90
  }
81
91
  else if (results) {
82
- return handleNestedQueries(results, originalQuery, options, queries.slice(1));
92
+ return handleNestedQueries({
93
+ element: results,
94
+ originalQuery,
95
+ options,
96
+ queries: queries.slice(1),
97
+ });
83
98
  }
84
99
  else {
85
100
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/web",
3
- "version": "31.73.1",
3
+ "version": "31.73.3",
4
4
  "description": "A collection of augments, helpers types, functions, and classes only for web (frontend) JavaScript environments.",
5
5
  "keywords": [
6
6
  "augment",
@@ -36,16 +36,16 @@
36
36
  "test:update": "npm test"
37
37
  },
38
38
  "dependencies": {
39
- "@augment-vir/assert": "^31.73.1",
40
- "@augment-vir/common": "^31.73.1",
41
- "@date-vir/duration": "^8.3.2",
39
+ "@augment-vir/assert": "^31.73.3",
40
+ "@augment-vir/common": "^31.73.3",
41
+ "@date-vir/duration": "^8.6.1",
42
42
  "html-spec-tags": "^2.2.3",
43
- "type-fest": "^5.6.0"
43
+ "type-fest": "^5.7.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@augment-vir/test": "^31.73.1",
46
+ "@augment-vir/test": "^31.73.3",
47
47
  "bowser": "^2.14.1",
48
- "typescript": "^5.9.3"
48
+ "typescript": "^6.0.3"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "element-vir": ">=22.0.0"