Browse Source

@uppy/utils: avoid creating throw-away <div> in `isDragDropSupported` (#3080)

Antoine du Hamel 3 năm trước cách đây
mục cha
commit
126984ece3
2 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 1 0
      bin/locale-packs.js
  2. 1 1
      packages/@uppy/utils/src/isDragDropSupported.js

+ 1 - 0
bin/locale-packs.js

@@ -73,6 +73,7 @@ function buildPluginsList () {
       createElement: () => {
         return { style: {} }
       },
+      get body () { return this.createElement() },
     }
 
     try {

+ 1 - 1
packages/@uppy/utils/src/isDragDropSupported.js

@@ -4,7 +4,7 @@
  * @returns {boolean}
  */
 module.exports = function isDragDropSupported () {
-  const div = document.createElement('div')
+  const div = document.body
 
   if (!('draggable' in div) || !('ondragstart' in div && 'ondrop' in div)) {
     return false