@vaadin/component-base 23.0.10 → 23.0.13
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 +2 -2
- package/src/dom-utils.d.ts +14 -0
- package/src/dom-utils.js +41 -0
- package/src/element-mixin.js +1 -1
- package/src/focus-trap-controller.js +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/component-base",
|
|
3
|
-
"version": "23.0.
|
|
3
|
+
"version": "23.0.13",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
43
43
|
"sinon": "^9.2.4"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "e915550ec6400b5eae6c779fe0afeb1931399312"
|
|
46
46
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns an array of ancestor root nodes for the given node.
|
|
9
|
+
*
|
|
10
|
+
* A root node is either a document node or a document fragment node (Shadow Root).
|
|
11
|
+
* The array is collected by a bottom-up DOM traversing that starts with the given node
|
|
12
|
+
* and involves both the light DOM and ancestor shadow DOM trees.
|
|
13
|
+
*/
|
|
14
|
+
export function getAncestorRootNodes(node: Node): Node[];
|
package/src/dom-utils.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns an array of ancestor root nodes for the given node.
|
|
9
|
+
*
|
|
10
|
+
* A root node is either a document node or a document fragment node (Shadow Root).
|
|
11
|
+
* The array is collected by a bottom-up DOM traversing that starts with the given node
|
|
12
|
+
* and involves both the light DOM and ancestor shadow DOM trees.
|
|
13
|
+
*
|
|
14
|
+
* @param {Node} node
|
|
15
|
+
* @return {Node[]}
|
|
16
|
+
*/
|
|
17
|
+
export function getAncestorRootNodes(node) {
|
|
18
|
+
const result = [];
|
|
19
|
+
|
|
20
|
+
while (node) {
|
|
21
|
+
if (node.nodeType === Node.DOCUMENT_NODE) {
|
|
22
|
+
result.push(node);
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
27
|
+
result.push(node);
|
|
28
|
+
node = node.host;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (node.assignedSlot) {
|
|
33
|
+
node = node.assignedSlot;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
node = node.parentNode;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return result;
|
|
41
|
+
}
|
package/src/element-mixin.js
CHANGED
|
@@ -125,7 +125,11 @@ export class FocusTrapController {
|
|
|
125
125
|
const step = backward ? -1 : 1;
|
|
126
126
|
const currentIndex = this.__focusedElementIndex;
|
|
127
127
|
const nextIndex = (focusableElements.length + currentIndex + step) % focusableElements.length;
|
|
128
|
-
focusableElements[nextIndex]
|
|
128
|
+
const element = focusableElements[nextIndex];
|
|
129
|
+
element.focus();
|
|
130
|
+
if (element.localName === 'input') {
|
|
131
|
+
element.select();
|
|
132
|
+
}
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
/**
|