Skip to content

Commit

Permalink
Add additional check for mutation observer
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerJDev committed Aug 21, 2024
1 parent b33926f commit 810400d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/focus-trap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ function observeFocusTrap(container: HTMLElement, sentinels: HTMLElement[]) {
for (const mutation of mutations) {
console.log('Mutations:', mutations)

Check failure on line 38 in src/focus-trap.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
if (mutation.type === 'childList' && mutation.addedNodes.length) {
const sentinelChildren = Array.from(
mutation.addedNodes,
e => e instanceof HTMLElement && e.classList.contains('sentinel') && e.tagName === 'SPAN',
)

// If any of the added nodes are sentinels, don't do anything
if (sentinelChildren.length) {
return
}
console.log('ChildList Mutation')

Check failure on line 49 in src/focus-trap.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
// If the first and last children of container aren't sentinels, move them to the start and end
const firstChild = container.firstElementChild
Expand Down

0 comments on commit 810400d

Please sign in to comment.