Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import { Window } from '../types';
*/
export default function getDocumentElement(element: Element | Window): HTMLElement {
// $FlowFixMe: assume body is always available
return (isElement(element) ? element.ownerDocument : element.document).documentElement;
return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ type State = {

const EMPTY_MODIFIERS: any = [];

function isReferenceConnected(reference: Element | VirtualElement): boolean {
if (reference instanceof Element) {
return reference.isConnected;
}
const { contextElement } = reference;
if (contextElement instanceof Element) {
return contextElement.isConnected;
}
return true;
}

export const usePopper = (
referenceElement: (Element | VirtualElement) | null | undefined,
popperElement: HTMLElement | null | undefined,
Expand Down Expand Up @@ -114,6 +125,10 @@ export const usePopper = (
return;
}

if (!isReferenceConnected(referenceElement) || !popperElement.isConnected) {
return;
}

const createPopper = options.createPopper || defaultCreatePopper;
const popperInstance = createPopper(referenceElement, popperElement, popperOptions);

Expand Down
16 changes: 0 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5477,13 +5477,6 @@ __metadata:
languageName: node
linkType: hard

"@types/cookie@npm:^0.6.0":
version: 0.6.0
resolution: "@types/cookie@npm:0.6.0"
checksum: 10c0/5b326bd0188120fb32c0be086b141b1481fec9941b76ad537f9110e10d61ee2636beac145463319c71e4be67a17e85b81ca9e13ceb6e3bb63b93d16824d6c149
languageName: node
linkType: hard

"@types/d3-array@npm:^3.0.3":
version: 3.2.1
resolution: "@types/d3-array@npm:3.2.1"
Expand Down Expand Up @@ -19339,10 +19332,8 @@ __metadata:
version: 7.13.0
resolution: "react-router@npm:7.13.0"
dependencies:
"@types/cookie": "npm:^0.6.0"
cookie: "npm:^1.0.1"
set-cookie-parser: "npm:^2.6.0"
turbo-stream: "npm:2.4.0"
peerDependencies:
react: ">=18"
react-dom: ">=18"
Expand Down Expand Up @@ -22550,13 +22541,6 @@ __metadata:
languageName: node
linkType: hard

"turbo-stream@npm:2.4.0":
version: 2.4.0
resolution: "turbo-stream@npm:2.4.0"
checksum: 10c0/e68b2569f1f16e6e9633d090c6024b2ae9f0e97bfeacb572451ca3732e120ebbb546f3bc4afc717c46cb57b5aea6104e04ef497f9912eef6a7641e809518e98a
languageName: node
linkType: hard

"tweetnacl@npm:^0.14.3, tweetnacl@npm:~0.14.0":
version: 0.14.5
resolution: "tweetnacl@npm:0.14.5"
Expand Down
Loading