Skip to content

Commit

Permalink
Fix: getOwnerDocument should get correct document for SVG Elements (#…
Browse files Browse the repository at this point in the history
…1239)

Co-authored-by: petdud <petrduda@microsoft.com>
  • Loading branch information
petdud and petdud committed Sep 25, 2023
1 parent 5c58f0f commit f342d5e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/owner-doc-for-svg-elements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@dnd-kit/utilities": patch
---

Fix: getOwnerDocument should get correct document for SVG Elements
10 changes: 8 additions & 2 deletions packages/utilities/src/execution-context/getOwnerDocument.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {isWindow, isHTMLElement, isDocument, isNode} from '../type-guards';
import {
isWindow,
isHTMLElement,
isDocument,
isNode,
isSVGElement,
} from '../type-guards';

export function getOwnerDocument(target: Event['target']): Document {
if (!target) {
Expand All @@ -17,7 +23,7 @@ export function getOwnerDocument(target: Event['target']): Document {
return target;
}

if (isHTMLElement(target)) {
if (isHTMLElement(target) || isSVGElement(target)) {
return target.ownerDocument;
}

Expand Down

0 comments on commit f342d5e

Please sign in to comment.