Skip to content

Commit cea9065

Browse files
authored
feat(utils): allow reuse of existing computed style in isContainingBlock (floating-ui#2980)
1 parent 81a7da4 commit cea9065

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.changeset/early-emus-destroy.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@floating-ui/utils": patch
3+
---
4+
5+
feat(getContainingBlock): allow `CSSStyleDeclaration` as an argument

packages/utils/src/dom.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ export function isTopLayer(element: Element): boolean {
6868
});
6969
}
7070

71-
export function isContainingBlock(element: Element): boolean {
71+
export function isContainingBlock(element: Element): boolean;
72+
export function isContainingBlock(css: CSSStyleDeclaration): boolean;
73+
export function isContainingBlock(elementOrCss: Element | CSSStyleDeclaration): boolean {
7274
const webkit = isWebKit();
73-
const css = getComputedStyle(element);
75+
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
7476

7577
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
7678
return (

0 commit comments

Comments
 (0)