Skip to content

Commit

Permalink
feat: add defaults for dom util methods
Browse files Browse the repository at this point in the history
- Using `document` retains the behaviour from v1.0.7
- Widened type on each to `ParentNode | HTMLElement` (`document` requires `ParentNode`)
  • Loading branch information
psychedelicious committed Jan 12, 2024
1 parent f72d5a8 commit 2e1d075
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function getPanelElement(
id: string,
panelGroupElement: HTMLElement
panelGroupElement: ParentNode | HTMLElement = document
): HTMLElement | null {
const element = panelGroupElement.querySelector(`[data-panel-id="${id}"]`);
if (element) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function getPanelElementsForGroup(
groupId: string,
panelGroupElement: HTMLElement
panelGroupElement: ParentNode | HTMLElement = document
): HTMLElement[] {
return Array.from(
panelGroupElement.querySelectorAll(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function getPanelGroupElement(
id: string,
rootElement: ParentNode | HTMLElement
rootElement: ParentNode | HTMLElement = document
): HTMLElement | null {
//If the root element is the PanelGroup
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function getResizeHandleElement(
id: string,
panelGroupElement: ParentNode
panelGroupElement: ParentNode | HTMLElement = document
): HTMLElement | null {
const element = panelGroupElement.querySelector(
`[data-panel-resize-handle-id="${id}"]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getResizeHandleElementsForGroup } from "./getResizeHandleElementsForGro
export function getResizeHandleElementIndex(
groupId: string,
id: string,
panelGroupElement: ParentNode
panelGroupElement: ParentNode | HTMLElement = document
): number | null {
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
const index = handles.findIndex(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function getResizeHandleElementsForGroup(
groupId: string,
panelGroupElement: ParentNode
panelGroupElement: ParentNode | HTMLElement = document
): HTMLElement[] {
return Array.from(
panelGroupElement.querySelectorAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function getResizeHandlePanelIds(
groupId: string,
handleId: string,
panelsArray: PanelData[],
panelGroupElement: ParentNode
panelGroupElement: ParentNode | HTMLElement = document
): [idBefore: string | null, idAfter: string | null] {
const handle = getResizeHandleElement(handleId, panelGroupElement);
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
Expand Down

0 comments on commit 2e1d075

Please sign in to comment.