@vaadin/component-base 24.1.0-rc1 → 24.1.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/component-base",
3
- "version": "24.1.0-rc1",
3
+ "version": "24.1.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@esm-bundle/chai": "^4.3.4",
42
- "@vaadin/testing-helpers": "^0.4.0",
42
+ "@vaadin/testing-helpers": "^0.4.2",
43
43
  "sinon": "^13.0.2"
44
44
  },
45
- "gitHead": "ae09abc65ea9616629a8924688bb841b5075e0d2"
45
+ "gitHead": "c3a3d904885bd37ebb07a84b09617a340b4fab7e"
46
46
  }
@@ -13,6 +13,12 @@
13
13
  */
14
14
  export function getAncestorRootNodes(node: Node): Node[];
15
15
 
16
+ /**
17
+ * Traverses the given node and its parents, including those that are across
18
+ * the shadow root boundaries, until it finds a node that matches the selector.
19
+ */
20
+ export function getClosestElement(selector: string, node: Node): Node | null;
21
+
16
22
  /**
17
23
  * Takes a string with values separated by space and returns a set the values
18
24
  */
package/src/dom-utils.js CHANGED
@@ -40,6 +40,22 @@ export function getAncestorRootNodes(node) {
40
40
  return result;
41
41
  }
42
42
 
43
+ /**
44
+ * Traverses the given node and its parents, including those that are across
45
+ * the shadow root boundaries, until it finds a node that matches the selector.
46
+ *
47
+ * @param {string} selector The CSS selector to match against
48
+ * @param {Node} node The starting node for the traversal
49
+ * @return {Node | null} The closest matching element, or null if no match is found
50
+ */
51
+ export function getClosestElement(selector, node) {
52
+ if (!node) {
53
+ return null;
54
+ }
55
+
56
+ return node.closest(selector) || getClosestElement(selector, node.getRootNode().host);
57
+ }
58
+
43
59
  /**
44
60
  * Takes a string with values separated by space and returns a set the values
45
61
  *
@@ -45,7 +45,7 @@ const registered = new Set();
45
45
  export const ElementMixin = (superClass) =>
46
46
  class VaadinElementMixin extends DirMixin(superClass) {
47
47
  static get version() {
48
- return '24.1.0-rc1';
48
+ return '24.1.1';
49
49
  }
50
50
 
51
51
  /** @protected */