chekc for body null (#5959)

fixes #5953

---------

Co-authored-by: Prakash <qxprakash@gmail.com>
This commit is contained in:
Mikael Finstad 2025-09-11 23:14:24 +02:00 committed by GitHub
parent a72af02b79
commit 9bac4c8398
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
"@uppy/utils": patch
---
Fix `TypeError: Cannot use 'in' operator to search for 'draggable' in null`

View file

@ -2,9 +2,22 @@
* Checks if the browser supports Drag & Drop (not supported on mobile devices, for example).
*/
export default function isDragDropSupported(): boolean {
const div = document.body
if (typeof window === 'undefined') {
return false
}
if (!('draggable' in div) || !('ondragstart' in div && 'ondrop' in div)) {
const body = document.body
// sometimes happens in the wild: https://github.com/transloadit/uppy/issues/5953
if (body == null || window == null) {
return false
}
if (
!('draggable' in body) ||
!('ondragstart' in body) ||
!('ondrop' in body)
) {
return false
}