Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: parent cycle problem #317

Merged
merged 8 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
node_modules
packages/react-resizable-panels/dist
packages/react-resizable-panels-website/.cache
packages/react-resizable-panels-website/dist
packages/react-resizable-panels-website/dist
packages/react-resizable-panels/src/vendor/stacking-order.ts
14 changes: 10 additions & 4 deletions packages/react-resizable-panels/src/vendor/stacking-order.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Forked from NPM stacking-order@2.0.0
// Background at https://github.com/Rich-Harris/stacking-order/issues/3
// Background at https://github.com/Rich-Harris/stacking-order/issues/6

import { assert } from "..";

Expand Down Expand Up @@ -61,7 +62,8 @@ const props =

/** @param {HTMLElement} node */
function is_flex_item(node: HTMLElement) {
const display = getComputedStyle(get_parent(node)).display;
// @ts-ignore
const display = getComputedStyle(get_parent(node) ?? node).display;
return display === "flex" || display === "inline-flex";
}

Expand Down Expand Up @@ -115,11 +117,12 @@ function get_z_index(node: HTMLElement | null) {
}

/** @param {HTMLElement} node */
function get_ancestors(node: HTMLElement) {
function get_ancestors(node: HTMLElement | null) {
const ancestors = [];

while (node) {
ancestors.push(node);
// @ts-ignore
node = get_parent(node);
}

Expand All @@ -128,6 +131,9 @@ function get_ancestors(node: HTMLElement) {

/** @param {HTMLElement} node */
function get_parent(node: HTMLElement) {
// @ts-ignore
return node.parentNode?.host || node.parentNode;
const { parentNode } = node;
if (parentNode && parentNode instanceof ShadowRoot) {
return parentNode.host
}
return parentNode;
}
Loading