Skip to content

Commit

Permalink
Add logs to test performance
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerJDev committed Aug 14, 2024
1 parent 6a888bf commit b33926f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/focus-trap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,28 @@ function followSignal(signal: AbortSignal): AbortController {
}

function observeFocusTrap(container: HTMLElement, sentinels: HTMLElement[]) {
console.log('Observe Focus Trap Init')

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

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
const observer = new MutationObserver(mutations => {
console.log('New mutation')

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

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
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) {
console.log('ChildList Mutation')

Check failure on line 40 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
const lastChild = container.lastElementChild

const [sentinelStart, sentinelEnd] = sentinels

// Adds back sentinel to correct position in the DOM
if (!firstChild?.classList.contains('sentinel')) container.insertAdjacentElement('afterbegin', sentinelStart)
if (!lastChild?.classList.contains('sentinel')) container.insertAdjacentElement('beforeend', sentinelEnd)
if (!firstChild?.classList.contains('sentinel')) {
container.insertAdjacentElement('afterbegin', sentinelStart)
console.log('Adjust sentinel to start')

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

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
}
if (!lastChild?.classList.contains('sentinel')) {
container.insertAdjacentElement('beforeend', sentinelEnd)
console.log('Adjust sentinel to end')

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

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
}
}
}
})
Expand Down

0 comments on commit b33926f

Please sign in to comment.