diff --git a/src/__tests__/anchored-position.test.ts b/src/__tests__/anchored-position.test.ts
index df5466d..98707b3 100644
--- a/src/__tests__/anchored-position.test.ts
+++ b/src/__tests__/anchored-position.test.ts
@@ -21,7 +21,7 @@ function makeDOMRect(x: number, y: number, width: number, height: number): DOMRe
bottom: y + height,
toJSON() {
return this
- }
+ },
}
}
@@ -31,7 +31,7 @@ function createVirtualDOM(
parentRect: DOMRect,
anchorRect: DOMRect,
floatingRect: DOMRect,
- parentBorders: {top: number; right: number; bottom: number; left: number} = {top: 0, right: 0, bottom: 0, left: 0}
+ parentBorders: {top: number; right: number; bottom: number; left: number} = {top: 0, right: 0, bottom: 0, left: 0},
) {
const parent = document.createElement('div')
parent.style.overflow = 'hidden'
@@ -280,7 +280,7 @@ describe('getAnchoredPosition', () => {
side: 'outside-right',
align: 'center',
alignmentOffset: 10,
- anchorOffset: -10
+ anchorOffset: -10,
}
const {top, left} = getAnchoredPosition(float, anchor, settings)
@@ -301,7 +301,7 @@ describe('getAnchoredPosition', () => {
side: 'inside-right',
align: 'center',
alignmentOffset: 10,
- anchorOffset: -10
+ anchorOffset: -10,
}
const {top, left} = getAnchoredPosition(float, anchor, settings)
diff --git a/src/__tests__/focus-trap.test.tsx b/src/__tests__/focus-trap.test.tsx
index 143350c..5c936e6 100644
--- a/src/__tests__/focus-trap.test.tsx
+++ b/src/__tests__/focus-trap.test.tsx
@@ -9,14 +9,14 @@ beforeAll(() => {
try {
Object.defineProperties(HTMLElement.prototype, {
offsetHeight: {
- get: () => 42
+ get: () => 42,
},
offsetWidth: {
- get: () => 42
+ get: () => 42,
},
getClientRects: {
- get: () => () => [42]
- }
+ get: () => () => [42],
+ },
})
} catch {
// ignore
@@ -32,7 +32,7 @@ it('Should initially focus the first element when activated', () => {
-
+ ,
)
const trapContainer = container.querySelector('#trapContainer')!
@@ -49,7 +49,7 @@ it('Should initially focus the initialFocus element when specified', () => {
-
+ ,
)
const trapContainer = container.querySelector('#trapContainer')!
@@ -71,7 +71,7 @@ it('Should prevent focus from exiting the trap, returns focus to first element',
-
+ ,
)
const trapContainer = container.querySelector('#trapContainer')!
@@ -107,7 +107,7 @@ it('Should cycle focus from last element to first element and vice-versa', async
-
+ ,
)
const trapContainer = container.querySelector('#trapContainer')!
@@ -137,7 +137,7 @@ it('Should should release the trap when the signal is aborted', async () => {
-
+ ,
)
const trapContainer = container.querySelector('#trapContainer')!
@@ -167,7 +167,7 @@ it('Should should release the trap when the container is removed from the DOM',
-
+ ,
)
const trapContainer = container.querySelector('#trapContainer')!
@@ -198,7 +198,7 @@ it('Should handle dynamic content', async () => {
-
+ ,
)
const trapContainer = container.querySelector('#trapContainer')!
diff --git a/src/__tests__/focus-zone.test.tsx b/src/__tests__/focus-zone.test.tsx
index 3ed6fa9..f6d41c8 100644
--- a/src/__tests__/focus-zone.test.tsx
+++ b/src/__tests__/focus-zone.test.tsx
@@ -16,14 +16,14 @@ beforeAll(() => {
try {
Object.defineProperties(HTMLElement.prototype, {
offsetHeight: {
- get: () => 42
+ get: () => 42,
},
offsetWidth: {
- get: () => 42
+ get: () => 42,
},
getClientRects: {
- get: () => () => [42]
- }
+ get: () => () => [42],
+ },
})
} catch {
// ignore
@@ -39,7 +39,7 @@ it('Should allow arrow keys to move focus', () => {
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -65,7 +65,7 @@ it('Should have one tab-stop inside the focus zone when enabled', () => {
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -96,7 +96,7 @@ it('Should prevent moving focus outside the zone', () => {
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -130,7 +130,7 @@ it('Should do focus wrapping correctly', () => {
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -164,7 +164,7 @@ it('Should call custom getNextFocusable callback', () => {
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -195,7 +195,7 @@ it('Should focus-in to the most recently-focused element', () => {
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -228,7 +228,7 @@ it('Should focus-in to the first element when focusInStrategy is "first"', () =>
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -270,7 +270,7 @@ it('Should focus-in to the closest element when focusInStrategy is "closest"', (
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -309,7 +309,7 @@ it('Should call the custom focusInStrategy callback', () => {
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -340,7 +340,7 @@ it('Should respect inputs by not moving focus if key would have some other effec
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -372,7 +372,7 @@ it('Should focus-in to the first element if the last-focused element is removed'
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -411,7 +411,7 @@ it('Should call onActiveDescendantChanged properly', () => {
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -420,7 +420,7 @@ it('Should call onActiveDescendantChanged properly', () => {
const activeDescendantChangedCallback = jest.fn()
const controller = focusZone(focusZoneContainer, {
activeDescendantControl: control,
- onActiveDescendantChanged: activeDescendantChangedCallback
+ onActiveDescendantChanged: activeDescendantChangedCallback,
})
type ActiveDescendantChangedCallbackParameters = Parameters<
Exclude
@@ -430,37 +430,37 @@ it('Should call onActiveDescendantChanged properly', () => {
expect(activeDescendantChangedCallback).toHaveBeenLastCalledWith(
firstButton,
undefined,
- false
+ false,
)
userEvent.type(control, '{arrowdown}')
expect(activeDescendantChangedCallback).toHaveBeenLastCalledWith(
secondButton,
firstButton,
- true
+ true,
)
userEvent.type(control, '{arrowup}')
expect(activeDescendantChangedCallback).toHaveBeenLastCalledWith(
firstButton,
secondButton,
- true
+ true,
)
fireEvent.mouseMove(secondButton)
expect(activeDescendantChangedCallback).toHaveBeenLastCalledWith(
secondButton,
firstButton,
- false
+ false,
)
userEvent.type(control, '{arrowup}')
expect(activeDescendantChangedCallback).toHaveBeenLastCalledWith(
firstButton,
secondButton,
- true
+ true,
)
userEvent.type(control, '{arrowUp}')
expect(activeDescendantChangedCallback).toHaveBeenLastCalledWith(
firstButton,
firstButton,
- true
+ true,
)
activeDescendantChangedCallback.mockReset()
fireEvent.mouseMove(firstButton)
@@ -481,7 +481,7 @@ it('Should set aria-activedescendant correctly', () => {
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
@@ -514,7 +514,7 @@ it('Should handle elements being reordered', async () => {
-
+ ,
)
const focusZoneContainer = container.querySelector('#focusZone')!
diff --git a/src/__tests__/iterate-focusable-elements.test.tsx b/src/__tests__/iterate-focusable-elements.test.tsx
index b98bbfd..7c309cc 100644
--- a/src/__tests__/iterate-focusable-elements.test.tsx
+++ b/src/__tests__/iterate-focusable-elements.test.tsx
@@ -17,7 +17,7 @@ it('Should iterate through focusable elements only', () => {
Focusable
-
+ ,
)
const focusable = Array.from(iterateFocusableElements(container as HTMLElement, {onlyTabbable: true}))
@@ -45,7 +45,7 @@ it('Should iterate through focusable elements in reverse', () => {
Focusable
-
+ ,
)
const focusable = Array.from(iterateFocusableElements(container as HTMLElement, {reverse: true, onlyTabbable: true}))
diff --git a/src/__tests__/scroll-into-view.test.ts b/src/__tests__/scroll-into-view.test.ts
index 143317e..3111ed0 100644
--- a/src/__tests__/scroll-into-view.test.ts
+++ b/src/__tests__/scroll-into-view.test.ts
@@ -2,7 +2,7 @@ import {scrollIntoView} from '../scroll-into-view.js'
function scrollPositionFormula(
positionData: {viewingAreaEdgePosition: number; childEdgePosition: number; margin: number},
- isChildAboveViewingArea: boolean
+ isChildAboveViewingArea: boolean,
) {
const {viewingAreaEdgePosition, childEdgePosition, margin} = positionData
const marginOffset = margin * (isChildAboveViewingArea ? -1 : 1)
@@ -23,7 +23,7 @@ function makeDOMRect(x: number, y: number, width: number, height: number): DOMRe
bottom: y + height,
toJSON() {
return this
- }
+ },
}
}
@@ -45,14 +45,14 @@ describe('scrollIntoView', () => {
const scrollToMock = jest.fn()
Object.defineProperty(window.Element.prototype, 'scrollTo', {
writable: true,
- value: scrollToMock
+ value: scrollToMock,
})
const childHeight = 50
const viewAreaHeight = 100
const childStart = viewAreaHeight + 10
const expectedScrollPosition = scrollPositionFormula(
{viewingAreaEdgePosition: viewAreaHeight, childEdgePosition: childStart + childHeight, margin: 0},
- false
+ false,
)
const viewingAreaRect = makeDOMRect(0, 0, 100, viewAreaHeight)
@@ -66,7 +66,7 @@ describe('scrollIntoView', () => {
scrollIntoView(child as HTMLDivElement, viewingArea)
expect(scrollToMock).toHaveBeenCalledWith({
behavior: 'smooth',
- top: expectedScrollPosition
+ top: expectedScrollPosition,
})
})
@@ -75,7 +75,7 @@ describe('scrollIntoView', () => {
const scrollToMock = jest.fn()
Object.defineProperty(window.Element.prototype, 'scrollTo', {
writable: true,
- value: scrollToMock
+ value: scrollToMock,
})
const childHeight = 50
const viewAreaHeight = 100
@@ -83,7 +83,7 @@ describe('scrollIntoView', () => {
const scrollMargin = 10
const expectedScrollPosition = scrollPositionFormula(
{viewingAreaEdgePosition: viewAreaHeight, childEdgePosition: childStart + childHeight, margin: scrollMargin},
- false
+ false,
)
const viewingAreaRect = makeDOMRect(0, 0, 100, viewAreaHeight)
@@ -98,11 +98,11 @@ describe('scrollIntoView', () => {
direction: 'vertical',
startMargin: scrollMargin,
endMargin: scrollMargin,
- behavior: 'auto'
+ behavior: 'auto',
})
expect(scrollToMock).toHaveBeenCalledWith({
behavior: 'auto',
- top: expectedScrollPosition
+ top: expectedScrollPosition,
})
})
@@ -110,14 +110,14 @@ describe('scrollIntoView', () => {
const scrollToMock = jest.fn()
Object.defineProperty(window.Element.prototype, 'scrollTo', {
writable: true,
- value: scrollToMock
+ value: scrollToMock,
})
const childHeight = 50
const childStart = childHeight * -1 - 10
const scrollMargin = 10
const expectedScrollPosition = scrollPositionFormula(
{viewingAreaEdgePosition: 0, childEdgePosition: childStart, margin: scrollMargin},
- true
+ true,
)
const viewingAreaRect = makeDOMRect(0, 0, 100, 100)
@@ -132,11 +132,11 @@ describe('scrollIntoView', () => {
direction: 'vertical',
startMargin: scrollMargin,
endMargin: scrollMargin,
- behavior: 'auto'
+ behavior: 'auto',
})
expect(scrollToMock).toHaveBeenCalledWith({
behavior: 'auto',
- top: expectedScrollPosition
+ top: expectedScrollPosition,
})
})
})
@@ -146,7 +146,7 @@ describe('scrollIntoView', () => {
const scrollToMock = jest.fn()
Object.defineProperty(window.Element.prototype, 'scrollTo', {
writable: true,
- value: scrollToMock
+ value: scrollToMock,
})
const childWidth = 50
const viewAreaWidth = 100
@@ -154,7 +154,7 @@ describe('scrollIntoView', () => {
const scrollMargin = 10
const expectedScrollPosition = scrollPositionFormula(
{viewingAreaEdgePosition: viewAreaWidth, childEdgePosition: childStart + childWidth, margin: scrollMargin},
- false
+ false,
)
const viewingAreaRect = makeDOMRect(0, 0, 100, viewAreaWidth)
@@ -169,11 +169,11 @@ describe('scrollIntoView', () => {
direction: 'horizontal',
startMargin: scrollMargin,
endMargin: scrollMargin,
- behavior: 'auto'
+ behavior: 'auto',
})
expect(scrollToMock).toHaveBeenCalledWith({
behavior: 'auto',
- left: expectedScrollPosition
+ left: expectedScrollPosition,
})
})
@@ -181,14 +181,14 @@ describe('scrollIntoView', () => {
const scrollToMock = jest.fn()
Object.defineProperty(window.Element.prototype, 'scrollTo', {
writable: true,
- value: scrollToMock
+ value: scrollToMock,
})
const childWidth = 50
const childStart = childWidth * -1 - 10
const scrollMargin = 10
const expectedScrollPosition = scrollPositionFormula(
{viewingAreaEdgePosition: 0, childEdgePosition: childStart, margin: scrollMargin},
- true
+ true,
)
const viewingAreaRect = makeDOMRect(0, 0, 100, 100)
@@ -203,11 +203,11 @@ describe('scrollIntoView', () => {
direction: 'horizontal',
startMargin: scrollMargin,
endMargin: scrollMargin,
- behavior: 'auto'
+ behavior: 'auto',
})
expect(scrollToMock).toHaveBeenCalledWith({
behavior: 'auto',
- left: expectedScrollPosition
+ left: expectedScrollPosition,
})
})
})
diff --git a/src/anchored-position.ts b/src/anchored-position.ts
index fd7a583..fbc67e7 100644
--- a/src/anchored-position.ts
+++ b/src/anchored-position.ts
@@ -96,7 +96,7 @@ const alternateOrders: Partial> = {
start: ['end', 'center'],
end: ['start', 'center'],
- center: ['end', 'start']
+ center: ['end', 'start'],
}
interface Size {
@@ -140,7 +140,7 @@ interface BoxPosition extends Size, Position {}
export function getAnchoredPosition(
floatingElement: Element,
anchorElement: Element | DOMRect,
- settings: Partial = {}
+ settings: Partial = {},
): AnchorPosition {
const parentElement = getPositionedParent(floatingElement)
const clippingRect = getClippingRect(parentElement)
@@ -148,11 +148,11 @@ export function getAnchoredPosition(
const parentElementStyle = getComputedStyle(parentElement)
const parentElementRect = parentElement.getBoundingClientRect()
const [borderTop, borderLeft] = [parentElementStyle.borderTopWidth, parentElementStyle.borderLeftWidth].map(
- v => parseInt(v, 10) || 0
+ v => parseInt(v, 10) || 0,
)
const relativeRect = {
top: parentElementRect.top + borderTop,
- left: parentElementRect.left + borderLeft
+ left: parentElementRect.left + borderLeft,
}
return pureCalculateAnchoredPosition(
@@ -160,7 +160,7 @@ export function getAnchoredPosition(
relativeRect,
floatingElement.getBoundingClientRect(),
anchorElement instanceof Element ? anchorElement.getBoundingClientRect() : anchorElement,
- getDefaultSettings(settings)
+ getDefaultSettings(settings),
)
}
@@ -188,6 +188,7 @@ function isOnTopLayer(element: Element) {
return true
}
try {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
if (element.matches(':popover-open') && /native code/.test((document.body as any).showPopover?.toString())) {
return true
}
@@ -224,7 +225,7 @@ function getClippingRect(element: Element): BoxPosition {
elemStyle.borderTopWidth,
elemStyle.borderLeftWidth,
elemStyle.borderRightWidth,
- elemStyle.borderBottomWidth
+ elemStyle.borderBottomWidth,
].map(v => parseInt(v, 10) || 0)
return {
@@ -235,8 +236,8 @@ function getClippingRect(element: Element): BoxPosition {
// If the clipping node is document.body, it can expand to the full height of the window
height: Math.max(
elemRect.height - borderTop - borderBottom,
- clippingNode === document.body ? window.innerHeight : -Infinity
- )
+ clippingNode === document.body ? window.innerHeight : -Infinity,
+ ),
}
}
@@ -252,7 +253,7 @@ const positionDefaults: PositionSettings = {
// and align is not center
alignmentOffset: 4,
- allowOutOfBounds: false
+ allowOutOfBounds: false,
}
/**
@@ -271,7 +272,7 @@ function getDefaultSettings(settings: Partial = {}): PositionS
alignmentOffset:
settings.alignmentOffset ??
(align !== 'center' && side.startsWith('inside') ? positionDefaults.alignmentOffset : 0),
- allowOutOfBounds: settings.allowOutOfBounds ?? positionDefaults.allowOutOfBounds
+ allowOutOfBounds: settings.allowOutOfBounds ?? positionDefaults.allowOutOfBounds,
}
}
@@ -291,14 +292,14 @@ function pureCalculateAnchoredPosition(
relativePosition: Position,
floatingRect: Size,
anchorRect: BoxPosition,
- {side, align, allowOutOfBounds, anchorOffset, alignmentOffset}: PositionSettings
+ {side, align, allowOutOfBounds, anchorOffset, alignmentOffset}: PositionSettings,
): AnchorPosition {
// Compute the relative viewport rect, to bring it into the same coordinate space as `pos`
const relativeViewportRect: BoxPosition = {
top: viewportRect.top - relativePosition.top,
left: viewportRect.left - relativePosition.left,
width: viewportRect.width,
- height: viewportRect.height
+ height: viewportRect.height,
}
let pos = calculatePosition(floatingRect, anchorRect, side, align, anchorOffset, alignmentOffset)
@@ -396,7 +397,7 @@ function calculatePosition(
side: AnchorSide,
align: AnchorAlignment,
anchorOffset: number,
- alignmentOffset: number
+ alignmentOffset: number,
) {
const anchorRight = anchorPosition.left + anchorPosition.width
const anchorBottom = anchorPosition.top + anchorPosition.height
@@ -480,7 +481,7 @@ function shouldRecalculatePosition(
side: AnchorSide,
currentPos: Position,
containerDimensions: BoxPosition,
- elementDimensions: Size
+ elementDimensions: Size,
) {
if (side === 'outside-top' || side === 'outside-bottom') {
return (
@@ -506,7 +507,7 @@ function shouldRecalculateAlignment(
align: AnchorAlignment,
currentPos: Position,
containerDimensions: BoxPosition,
- elementDimensions: Size
+ elementDimensions: Size,
) {
if (align === 'end') {
return currentPos.left < containerDimensions.left
diff --git a/src/dimensions.ts b/src/dimensions.ts
index 908a9fb..21c7925 100644
--- a/src/dimensions.ts
+++ b/src/dimensions.ts
@@ -17,7 +17,7 @@ export function offset(element: HTMLElement): Offset {
const rect = element.getBoundingClientRect()
return {
top: rect.top + window.pageYOffset,
- left: rect.left + window.pageXOffset
+ left: rect.left + window.pageXOffset,
}
}
@@ -95,7 +95,7 @@ export function overflowParent(targetElement: HTMLElement): HTMLElement | null |
// //=> {top: 100, left: 100, bottom: 800, right: 800, height: 1000, width 1000}.
export function overflowOffset(
element: HTMLElement,
- targetContainer: Document | HTMLElement | null
+ targetContainer: Document | HTMLElement | null,
): Dimensions | undefined {
let container = targetContainer
const document = element.ownerDocument
@@ -123,11 +123,11 @@ export function overflowOffset(
container === document.documentElement && document.defaultView
? {
top: document.defaultView.pageYOffset,
- left: document.defaultView.pageXOffset
+ left: document.defaultView.pageXOffset,
}
: {
top: container.scrollTop,
- left: container.scrollLeft
+ left: container.scrollLeft,
}
const top = elementOffset.top - scroll.top
@@ -170,7 +170,7 @@ export function overflowOffset(
// This value is useful for assigning to `scrollTop` to scroll to the item.
export function positionedOffset(
targetElement: HTMLElement,
- container: HTMLElement | Document | Window | null
+ container: HTMLElement | Document | Window | null,
): (Dimensions & {_container: HTMLElement}) | undefined {
let element = targetElement
const document = element.ownerDocument
@@ -236,7 +236,7 @@ function getDocumentHeight(documentBody: HTMLElement, documentElement: HTMLEleme
documentElement.scrollHeight,
documentBody.offsetHeight,
documentElement.offsetHeight,
- documentElement.clientHeight
+ documentElement.clientHeight,
)
}
@@ -246,6 +246,6 @@ function getDocumentWidth(documentBody: HTMLElement, documentElement: HTMLElemen
documentElement.scrollWidth,
documentBody.offsetWidth,
documentElement.offsetWidth,
- documentElement.clientWidth
+ documentElement.clientWidth,
)
}
diff --git a/src/focus-trap.ts b/src/focus-trap.ts
index 7899dc0..c3de92e 100644
--- a/src/focus-trap.ts
+++ b/src/focus-trap.ts
@@ -39,7 +39,7 @@ function followSignal(signal: AbortSignal): AbortController {
export function focusTrap(
container: HTMLElement,
initialFocus?: HTMLElement,
- abortSignal?: AbortSignal
+ abortSignal?: AbortSignal,
): AbortController | undefined {
// Set up an abort controller if a signal was not passed in
const controller = new AbortController()
@@ -127,7 +127,7 @@ export function focusTrap(
ensureTrapZoneHasFocus(event.target)
},
// use capture to ensure we get all events. focus events do not bubble
- {signal: wrappingController.signal, capture: true}
+ {signal: wrappingController.signal, capture: true},
)
// focus the first element
@@ -137,7 +137,7 @@ export function focusTrap(
container,
controller: wrappingController,
initialFocus,
- originalSignal: signal
+ originalSignal: signal,
}
// If we are activating a focus trap for a container that was previously
diff --git a/src/focus-zone.ts b/src/focus-zone.ts
index bfaf704..c4bbcb4 100644
--- a/src/focus-zone.ts
+++ b/src/focus-zone.ts
@@ -66,7 +66,7 @@ export enum FocusKeys {
FocusKeys.HomeAndEnd |
FocusKeys.PageUpDown |
FocusKeys.WASD |
- FocusKeys.Tab
+ FocusKeys.Tab,
}
const KEY_TO_BIT = {
@@ -87,7 +87,7 @@ const KEY_TO_BIT = {
End: FocusKeys.HomeAndEnd,
PageUp: FocusKeys.PageUpDown,
PageDown: FocusKeys.PageUpDown,
- Backspace: FocusKeys.Backspace
+ Backspace: FocusKeys.Backspace,
} as {[k in FocusMovementKeys]: FocusKeys}
const KEY_TO_DIRECTION = {
@@ -108,7 +108,7 @@ const KEY_TO_DIRECTION = {
End: 'end',
PageUp: 'start',
PageDown: 'end',
- Backspace: 'previous'
+ Backspace: 'previous',
} as {[k in FocusMovementKeys]: Direction}
/**
@@ -195,7 +195,7 @@ export interface FocusZoneSettings {
onActiveDescendantChanged?: (
newActiveDescendant: HTMLElement | undefined,
previousActiveDescendant: HTMLElement | undefined,
- directlyActivated: boolean
+ directlyActivated: boolean,
) => void
/**
@@ -412,7 +412,7 @@ export function focusZone(container: HTMLElement, settings?: FocusZoneSettings):
container.setAttribute(hasActiveDescendantAttribute, to.id)
to.setAttribute(
isActiveDescendantAttribute,
- directlyActivated ? activeDescendantActivatedDirectly : activeDescendantActivatedIndirectly
+ directlyActivated ? activeDescendantActivatedDirectly : activeDescendantActivatedIndirectly,
)
activeDescendantCallback?.(to, from, directlyActivated)
}
@@ -534,7 +534,7 @@ export function focusZone(container: HTMLElement, settings?: FocusZoneSettings):
observer.observe(container, {
subtree: true,
- childList: true
+ childList: true,
})
const controller = new AbortController()
@@ -555,7 +555,7 @@ export function focusZone(container: HTMLElement, settings?: FocusZoneSettings):
elementIndexFocusedByClick = focusableElements.indexOf(event.target)
}
},
- {signal}
+ {signal},
)
if (activeDescendantControl) {
@@ -579,7 +579,7 @@ export function focusZone(container: HTMLElement, settings?: FocusZoneSettings):
updateFocusedElement(focusableElement)
}
},
- {signal, capture: true}
+ {signal, capture: true},
)
// Listeners specifically on the controlling element
@@ -649,7 +649,7 @@ export function focusZone(container: HTMLElement, settings?: FocusZoneSettings):
}
lastKeyboardFocusDirection = undefined
},
- {signal}
+ {signal},
)
}
@@ -666,7 +666,7 @@ export function focusZone(container: HTMLElement, settings?: FocusZoneSettings):
lastKeyboardFocusDirection = getDirection(event)
}
},
- {signal, capture: true}
+ {signal, capture: true},
)
}
@@ -752,7 +752,7 @@ export function focusZone(container: HTMLElement, settings?: FocusZoneSettings):
}
}
},
- {signal}
+ {signal},
)
return controller
}
diff --git a/src/polyfills/event-listener-signal.ts b/src/polyfills/event-listener-signal.ts
index 9427663..d7b4379 100644
--- a/src/polyfills/event-listener-signal.ts
+++ b/src/polyfills/event-listener-signal.ts
@@ -10,7 +10,6 @@ removed.
*/
let signalSupported = false
-// eslint-disable-next-line @typescript-eslint/no-empty-function
function noop() {}
try {
const options = Object.create(
@@ -19,9 +18,9 @@ try {
signal: {
get() {
signalSupported = true
- }
- }
- }
+ },
+ },
+ },
)
window.addEventListener('test', noop, options)
window.removeEventListener('test', noop, options)
diff --git a/src/scroll-into-view.ts b/src/scroll-into-view.ts
index 1387d68..a6de5cd 100644
--- a/src/scroll-into-view.ts
+++ b/src/scroll-into-view.ts
@@ -8,7 +8,7 @@ export interface ScrollIntoViewOptions {
export function scrollIntoView(
child: HTMLElement,
viewingArea: HTMLElement,
- {direction = 'vertical', startMargin = 0, endMargin = 0, behavior = 'smooth'}: ScrollIntoViewOptions = {}
+ {direction = 'vertical', startMargin = 0, endMargin = 0, behavior = 'smooth'}: ScrollIntoViewOptions = {},
) {
const startSide = direction === 'vertical' ? 'top' : 'left'
const endSide = direction === 'vertical' ? 'bottom' : 'right'
diff --git a/src/utils/iterate-focusable-elements.ts b/src/utils/iterate-focusable-elements.ts
index 732da7b..8dacb5d 100644
--- a/src/utils/iterate-focusable-elements.ts
+++ b/src/utils/iterate-focusable-elements.ts
@@ -28,13 +28,13 @@ export interface IterateFocusableElements {
*/
export function* iterateFocusableElements(
container: HTMLElement,
- options: IterateFocusableElements = {}
+ options: IterateFocusableElements = {},
): Generator {
const strict = options.strict ?? false
const acceptFn = options.onlyTabbable ?? false ? isTabbable : isFocusable
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
acceptNode: node =>
- node instanceof HTMLElement && acceptFn(node, strict) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
+ node instanceof HTMLElement && acceptFn(node, strict) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP,
})
let nextNode: Node | null = null