fix(desktop): apply getComputedStyle polyfill on all platforms (#9369)
This commit is contained in:
@@ -26,17 +26,16 @@ if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const isWindows = ostype() === "windows"
|
// Floating UI can call getComputedStyle with non-elements (e.g., null refs, virtual elements).
|
||||||
if (isWindows) {
|
// This happens on all platforms (WebView2 on Windows, WKWebView on macOS), not just Windows.
|
||||||
const originalGetComputedStyle = window.getComputedStyle
|
const originalGetComputedStyle = window.getComputedStyle
|
||||||
window.getComputedStyle = ((elt: Element, pseudoElt?: string | null) => {
|
window.getComputedStyle = ((elt: Element, pseudoElt?: string | null) => {
|
||||||
if (!(elt instanceof Element)) {
|
if (!(elt instanceof Element)) {
|
||||||
// WebView2 can call into Floating UI with non-elements; fall back to a safe element.
|
// Fall back to a safe element when a non-element is passed.
|
||||||
return originalGetComputedStyle(document.documentElement, pseudoElt ?? undefined)
|
return originalGetComputedStyle(document.documentElement, pseudoElt ?? undefined)
|
||||||
}
|
}
|
||||||
return originalGetComputedStyle(elt, pseudoElt ?? undefined)
|
return originalGetComputedStyle(elt, pseudoElt ?? undefined)
|
||||||
}) as typeof window.getComputedStyle
|
}) as typeof window.getComputedStyle
|
||||||
}
|
|
||||||
|
|
||||||
let update: Update | null = null
|
let update: Update | null = null
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user