@primer/behaviors 0.0.0-20240814142107 → 0.0.0-20240821162245
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/dist/cjs/focus-trap.js +14 -2
- package/dist/esm/focus-trap.mjs +14 -2
- package/package.json +1 -1
package/dist/cjs/focus-trap.js
CHANGED
|
@@ -20,16 +20,28 @@ function followSignal(signal) {
|
|
|
20
20
|
return controller;
|
|
21
21
|
}
|
|
22
22
|
function observeFocusTrap(container, sentinels) {
|
|
23
|
+
console.log('Observe Focus Trap Init');
|
|
23
24
|
const observer = new MutationObserver(mutations => {
|
|
25
|
+
console.log('New mutation');
|
|
24
26
|
for (const mutation of mutations) {
|
|
27
|
+
console.log('Mutations:', mutations);
|
|
25
28
|
if (mutation.type === 'childList' && mutation.addedNodes.length) {
|
|
29
|
+
const sentinelChildren = Array.from(mutation.addedNodes, e => e instanceof HTMLElement && e.classList.contains('sentinel') && e.tagName === 'SPAN');
|
|
30
|
+
if (sentinelChildren.length) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
console.log('ChildList Mutation');
|
|
26
34
|
const firstChild = container.firstElementChild;
|
|
27
35
|
const lastChild = container.lastElementChild;
|
|
28
36
|
const [sentinelStart, sentinelEnd] = sentinels;
|
|
29
|
-
if (!(firstChild === null || firstChild === void 0 ? void 0 : firstChild.classList.contains('sentinel')))
|
|
37
|
+
if (!(firstChild === null || firstChild === void 0 ? void 0 : firstChild.classList.contains('sentinel'))) {
|
|
30
38
|
container.insertAdjacentElement('afterbegin', sentinelStart);
|
|
31
|
-
|
|
39
|
+
console.log('Adjust sentinel to start');
|
|
40
|
+
}
|
|
41
|
+
if (!(lastChild === null || lastChild === void 0 ? void 0 : lastChild.classList.contains('sentinel'))) {
|
|
32
42
|
container.insertAdjacentElement('beforeend', sentinelEnd);
|
|
43
|
+
console.log('Adjust sentinel to end');
|
|
44
|
+
}
|
|
33
45
|
}
|
|
34
46
|
}
|
|
35
47
|
});
|
package/dist/esm/focus-trap.mjs
CHANGED
|
@@ -18,16 +18,28 @@ function followSignal(signal) {
|
|
|
18
18
|
return controller;
|
|
19
19
|
}
|
|
20
20
|
function observeFocusTrap(container, sentinels) {
|
|
21
|
+
console.log('Observe Focus Trap Init');
|
|
21
22
|
const observer = new MutationObserver(mutations => {
|
|
23
|
+
console.log('New mutation');
|
|
22
24
|
for (const mutation of mutations) {
|
|
25
|
+
console.log('Mutations:', mutations);
|
|
23
26
|
if (mutation.type === 'childList' && mutation.addedNodes.length) {
|
|
27
|
+
const sentinelChildren = Array.from(mutation.addedNodes, e => e instanceof HTMLElement && e.classList.contains('sentinel') && e.tagName === 'SPAN');
|
|
28
|
+
if (sentinelChildren.length) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
console.log('ChildList Mutation');
|
|
24
32
|
const firstChild = container.firstElementChild;
|
|
25
33
|
const lastChild = container.lastElementChild;
|
|
26
34
|
const [sentinelStart, sentinelEnd] = sentinels;
|
|
27
|
-
if (!(firstChild === null || firstChild === void 0 ? void 0 : firstChild.classList.contains('sentinel')))
|
|
35
|
+
if (!(firstChild === null || firstChild === void 0 ? void 0 : firstChild.classList.contains('sentinel'))) {
|
|
28
36
|
container.insertAdjacentElement('afterbegin', sentinelStart);
|
|
29
|
-
|
|
37
|
+
console.log('Adjust sentinel to start');
|
|
38
|
+
}
|
|
39
|
+
if (!(lastChild === null || lastChild === void 0 ? void 0 : lastChild.classList.contains('sentinel'))) {
|
|
30
40
|
container.insertAdjacentElement('beforeend', sentinelEnd);
|
|
41
|
+
console.log('Adjust sentinel to end');
|
|
42
|
+
}
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
45
|
});
|