mirror of
https://github.com/transloadit/uppy.git
synced 2026-01-23 02:25:07 +00:00
chekc for body null (#5959)
fixes #5953 --------- Co-authored-by: Prakash <qxprakash@gmail.com>
This commit is contained in:
parent
a72af02b79
commit
9bac4c8398
2 changed files with 20 additions and 2 deletions
5
.changeset/odd-walls-camp.md
Normal file
5
.changeset/odd-walls-camp.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@uppy/utils": patch
|
||||
---
|
||||
|
||||
Fix `TypeError: Cannot use 'in' operator to search for 'draggable' in null`
|
||||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue