Skip to content

Commit ddef5c7

Browse files
committed
use simpler version
1 parent a64bdd2 commit ddef5c7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/@headlessui-react/src/internal/floating.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ export function useFloatingPanel(
134134
() => placement,
135135
[
136136
JSON.stringify(placement, (_, v) => {
137-
if (typeof v === 'object' && v !== null && 'outerHTML' in v) {
138-
return v.outerHTML
139-
}
140-
return v
137+
// When we are trying to stringify a DOM element, we want to return the
138+
// `outerHTML` of the element. In all other cases, we want to return the
139+
// value as-is.
140+
// It's not safe enough to check whether `v` is an instanceof
141+
// `HTMLElement` because some tools (like AG Grid) polyfill it to be `{}`.
142+
return v?.outerHTML ?? v
141143
}),
142144
]
143145
)

0 commit comments

Comments
 (0)