1 |
|
2 |
|
3 | import { ArrayExt } from '@lumino/algorithm';
|
4 | import { UUID } from '@lumino/coreutils';
|
5 | import { ElementExt } from '@lumino/domutils';
|
6 |
|
7 |
|
8 |
|
9 | export var DOMUtils;
|
10 | (function (DOMUtils) {
|
11 | |
12 |
|
13 |
|
14 | function hitTestNodes(nodes, x, y) {
|
15 | return ArrayExt.findFirstIndex(nodes, node => {
|
16 | return ElementExt.hitTest(node, x, y);
|
17 | });
|
18 | }
|
19 | DOMUtils.hitTestNodes = hitTestNodes;
|
20 | |
21 |
|
22 |
|
23 | function findElement(parent, className) {
|
24 | return parent.querySelector(`.${className}`);
|
25 | }
|
26 | DOMUtils.findElement = findElement;
|
27 | |
28 |
|
29 |
|
30 | function findElements(parent, className) {
|
31 | return parent.getElementsByClassName(className);
|
32 | }
|
33 | DOMUtils.findElements = findElements;
|
34 | |
35 |
|
36 |
|
37 | function createDomID() {
|
38 | return `id-${UUID.uuid4()}`;
|
39 | }
|
40 | DOMUtils.createDomID = createDomID;
|
41 | |
42 |
|
43 |
|
44 |
|
45 | function hasActiveEditableElement(parent, root = document) {
|
46 | const element = root.activeElement;
|
47 | return !!(element &&
|
48 | parent.contains(element) &&
|
49 | (element.matches(':read-write') ||
|
50 | (element.shadowRoot &&
|
51 | hasActiveEditableElement(element.shadowRoot, element.shadowRoot))));
|
52 | }
|
53 | DOMUtils.hasActiveEditableElement = hasActiveEditableElement;
|
54 | })(DOMUtils || (DOMUtils = {}));
|
55 |
|
\ | No newline at end of file |