Socket
Socket
Sign inDemoInstall

drag-drop

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drag-drop - npm Package Compare versions

Comparing version 5.0.0 to 5.0.1

2

dragdrop.min.js

@@ -1,1 +0,1 @@

(function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,b.DragDrop=a()}})(function(){return function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;c<g.length;c++)a(g[c]);return a}return b}()({1:[function(a,b){function c(){throw new Error("setTimeout has not been defined")}function d(){throw new Error("clearTimeout has not been defined")}function e(a){if(l===setTimeout)return setTimeout(a,0);if((l===c||!l)&&setTimeout)return l=setTimeout,setTimeout(a,0);try{return l(a,0)}catch(b){try{return l.call(null,a,0)}catch(b){return l.call(this,a,0)}}}function f(a){if(m===clearTimeout)return clearTimeout(a);if((m===d||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(a);try{return m(a)}catch(b){try{return m.call(null,a)}catch(b){return m.call(this,a)}}}function g(){q&&o&&(q=!1,o.length?p=o.concat(p):r=-1,p.length&&h())}function h(){if(!q){var a=e(g);q=!0;for(var b=p.length;b;){for(o=p,p=[];++r<b;)o&&o[r].run();r=-1,b=p.length}o=null,q=!1,f(a)}}function j(a,b){this.fun=a,this.array=b}function k(){}var l,m,n=b.exports={};(function(){try{l="function"==typeof setTimeout?setTimeout:c}catch(a){l=c}try{m="function"==typeof clearTimeout?clearTimeout:d}catch(a){m=d}})();var o,p=[],q=!1,r=-1;n.nextTick=function(a){var b=Array(arguments.length-1);if(1<arguments.length)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];p.push(new j(a,b)),1!==p.length||q||e(h)},j.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=k,n.addListener=k,n.once=k,n.off=k,n.removeListener=k,n.removeAllListeners=k,n.emit=k,n.prependListener=k,n.prependOnceListener=k,n.listeners=function(){return[]},n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],2:[function(a,b){(function(a){b.exports=function(b,c){function d(b){function d(){c&&c(b,f),c=null}i?a.nextTick(d):d()}function e(a,b,c){f[a]=c,(0==--g||b)&&d(b)}var f,g,h,i=!0;Array.isArray(b)?(f=[],g=b.length):(h=Object.keys(b),f={},g=h.length),g?h?h.forEach(function(a){b[a](function(b,c){e(a,b,c)})}):b.forEach(function(a,b){a(function(a,c){e(b,a,c)})}):d(null),i=!1}}).call(this,a("_process"))},{_process:1}],"/":[function(a,b){function c(a,b){function e(){h.readEntries(function(a){0<a.length?(g=g.concat(Array.from(a)),e()):f()})}function f(){d(g.map(function(a){return function(b){c(a,b)}}),function(c,d){c?b(c):(d.push({fullPath:a.fullPath,name:a.name,isFile:!1,isDirectory:!0}),b(null,d))})}var g=[];if(a.isFile)a.file(function(c){c.fullPath=a.fullPath,c.isFile=!0,c.isDirectory=!1,b(null,c)},function(a){b(a)});else if(a.isDirectory){var h=a.createReader();e()}}b.exports=function(a,b){function e(a){return b.onDragEnter&&b.onDragEnter(a),a.stopPropagation(),a.preventDefault(),!1}function f(c){if(c.stopPropagation(),c.preventDefault(),b.onDragOver&&b.onDragOver(c),c.dataTransfer.items){var d=Array.from(c.dataTransfer.items),e=d.filter(function(a){return"file"===a.kind}),f=d.filter(function(a){return"string"===a.kind});if(0===e.length&&!b.onDropText)return;if(0===f.length&&!b.onDrop)return;if(0===e.length&&0===f.length)return}return a.classList.add("drag"),clearTimeout(k),c.dataTransfer.dropEffect="copy",!1}function g(a){return a.stopPropagation(),a.preventDefault(),b.onDragLeave&&b.onDragLeave(a),clearTimeout(k),k=setTimeout(i,50),!1}function h(a){a.stopPropagation(),a.preventDefault(),b.onDragLeave&&b.onDragLeave(a),clearTimeout(k),i();var e={x:a.clientX,y:a.clientY},f=a.dataTransfer.getData("text");if(f&&b.onDropText&&b.onDropText(f,e),b.onDrop&&a.dataTransfer.items){var g=a.dataTransfer.files,h=Array.from(a.dataTransfer.items).filter(function(a){return"file"===a.kind});if(0===h.length)return;d(h.map(function(a){return function(b){c(a.webkitGetAsEntry(),b)}}),function(a,c){if(a)throw a;var d=c.flat(),f=d.filter(function(a){return a.isFile}),h=d.filter(function(a){return a.isDirectory});b.onDrop(f,e,g,h)})}return!1}function i(){a.classList.remove("drag")}if("string"==typeof a){var j=a;if(a=window.document.querySelector(a),!a)throw new Error("\""+j+"\" does not match any HTML elements")}if(!a)throw new Error("\""+a+"\" is not a valid HTML element");"function"==typeof b&&(b={onDrop:b});var k;return a.addEventListener("dragenter",e,!1),a.addEventListener("dragover",f,!1),a.addEventListener("dragleave",g,!1),a.addEventListener("drop",h,!1),function(){i(),a.removeEventListener("dragenter",e,!1),a.removeEventListener("dragover",f,!1),a.removeEventListener("dragleave",g,!1),a.removeEventListener("drop",h,!1)}};var d=a("run-parallel")},{"run-parallel":2}]},{},[])("/")});
(function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,b.DragDrop=a()}})(function(){return function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;c<g.length;c++)a(g[c]);return a}return b}()({1:[function(a,b){function c(){throw new Error("setTimeout has not been defined")}function d(){throw new Error("clearTimeout has not been defined")}function e(a){if(l===setTimeout)return setTimeout(a,0);if((l===c||!l)&&setTimeout)return l=setTimeout,setTimeout(a,0);try{return l(a,0)}catch(b){try{return l.call(null,a,0)}catch(b){return l.call(this,a,0)}}}function f(a){if(m===clearTimeout)return clearTimeout(a);if((m===d||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(a);try{return m(a)}catch(b){try{return m.call(null,a)}catch(b){return m.call(this,a)}}}function g(){q&&o&&(q=!1,o.length?p=o.concat(p):r=-1,p.length&&h())}function h(){if(!q){var a=e(g);q=!0;for(var b=p.length;b;){for(o=p,p=[];++r<b;)o&&o[r].run();r=-1,b=p.length}o=null,q=!1,f(a)}}function j(a,b){this.fun=a,this.array=b}function k(){}var l,m,n=b.exports={};(function(){try{l="function"==typeof setTimeout?setTimeout:c}catch(a){l=c}try{m="function"==typeof clearTimeout?clearTimeout:d}catch(a){m=d}})();var o,p=[],q=!1,r=-1;n.nextTick=function(a){var b=Array(arguments.length-1);if(1<arguments.length)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];p.push(new j(a,b)),1!==p.length||q||e(h)},j.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=k,n.addListener=k,n.once=k,n.off=k,n.removeListener=k,n.removeAllListeners=k,n.emit=k,n.prependListener=k,n.prependOnceListener=k,n.listeners=function(){return[]},n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],2:[function(a,b){(function(a){b.exports=function(b,c){function d(b){function d(){c&&c(b,f),c=null}i?a.nextTick(d):d()}function e(a,b,c){f[a]=c,(0==--g||b)&&d(b)}var f,g,h,i=!0;Array.isArray(b)?(f=[],g=b.length):(h=Object.keys(b),f={},g=h.length),g?h?h.forEach(function(a){b[a](function(b,c){e(a,b,c)})}):b.forEach(function(a,b){a(function(a,c){e(b,a,c)})}):d(null),i=!1}}).call(this,a("_process"))},{_process:1}],"/":[function(a,b){function c(a,b){function e(a){a.readEntries(a=>{0<a.length?(g=g.concat(Array.from(a)),e()):f()})}function f(){d(g.map(a=>b=>{c(a,b)}),(c,d)=>{c?b(c):(d.push({fullPath:a.fullPath,name:a.name,isFile:!1,isDirectory:!0}),b(null,d))})}let g=[];if(a.isFile)a.file(c=>{c.fullPath=a.fullPath,c.isFile=!0,c.isDirectory=!1,b(null,c)},a=>{b(a)});else if(a.isDirectory){const b=a.createReader();e(b)}}b.exports=function(a,b){function e(a){return b.onDragEnter&&b.onDragEnter(a),a.stopPropagation(),a.preventDefault(),!1}function f(c){if(c.stopPropagation(),c.preventDefault(),b.onDragOver&&b.onDragOver(c),c.dataTransfer.items){const a=Array.from(c.dataTransfer.items),d=a.filter(a=>"file"===a.kind),e=a.filter(a=>"string"===a.kind);if(0===d.length&&!b.onDropText)return;if(0===e.length&&!b.onDrop)return;if(0===d.length&&0===e.length)return}return a.classList.add("drag"),clearTimeout(j),c.dataTransfer.dropEffect="copy",!1}function g(a){return a.stopPropagation(),a.preventDefault(),b.onDragLeave&&b.onDragLeave(a),clearTimeout(j),j=setTimeout(i,50),!1}function h(a){a.stopPropagation(),a.preventDefault(),b.onDragLeave&&b.onDragLeave(a),clearTimeout(j),i();const e={x:a.clientX,y:a.clientY},f=a.dataTransfer.getData("text");if(f&&b.onDropText&&b.onDropText(f,e),b.onDrop&&a.dataTransfer.items){const f=a.dataTransfer.files,g=Array.from(a.dataTransfer.items).filter(a=>"file"===a.kind);if(0===g.length)return;d(g.map(a=>b=>{c(a.webkitGetAsEntry(),b)}),(a,c)=>{if(a)throw a;const d=c.flat(),g=d.filter(a=>a.isFile),h=d.filter(a=>a.isDirectory);b.onDrop(g,e,f,h)})}return!1}function i(){a.classList.remove("drag")}if("string"==typeof a){const b=a;if(a=window.document.querySelector(a),!a)throw new Error(`"${b}" does not match any HTML elements`)}if(!a)throw new Error(`"${a}" is not a valid HTML element`);"function"==typeof b&&(b={onDrop:b});let j;return a.addEventListener("dragenter",e,!1),a.addEventListener("dragover",f,!1),a.addEventListener("dragleave",g,!1),a.addEventListener("drop",h,!1),function(){i(),a.removeEventListener("dragenter",e,!1),a.removeEventListener("dragover",f,!1),a.removeEventListener("dragleave",g,!1),a.removeEventListener("drop",h,!1)}};const d=a("run-parallel")},{"run-parallel":2}]},{},[])("/")});
module.exports = dragDrop
var parallel = require('run-parallel')
const parallel = require('run-parallel')
function dragDrop (elem, listeners) {
if (typeof elem === 'string') {
var selector = elem
const selector = elem
elem = window.document.querySelector(elem)
if (!elem) {
throw new Error('"' + selector + '" does not match any HTML elements')
throw new Error(`"${selector}" does not match any HTML elements`)
}

@@ -15,3 +15,3 @@ }

if (!elem) {
throw new Error('"' + elem + '" is not a valid HTML element')
throw new Error(`"${elem}" is not a valid HTML element`)
}

@@ -23,3 +23,3 @@

var timeout
let timeout

@@ -62,5 +62,5 @@ elem.addEventListener('dragenter', onDragEnter, false)

// handled by the registered listeners (files vs. text)
var items = Array.from(e.dataTransfer.items)
var fileItems = items.filter(function (item) { return item.kind === 'file' })
var textItems = items.filter(function (item) { return item.kind === 'string' })
const items = Array.from(e.dataTransfer.items)
const fileItems = items.filter(item => { return item.kind === 'file' })
const textItems = items.filter(item => { return item.kind === 'string' })

@@ -105,3 +105,3 @@ if (fileItems.length === 0 && !listeners.onDropText) return

var pos = {
const pos = {
x: e.clientX,

@@ -112,3 +112,3 @@ y: e.clientY

// text drop support
var text = e.dataTransfer.getData('text')
const text = e.dataTransfer.getData('text')
if (text && listeners.onDropText) {

@@ -123,6 +123,6 @@ listeners.onDropText(text, pos)

if (listeners.onDrop && e.dataTransfer.items) {
var fileList = e.dataTransfer.files
const fileList = e.dataTransfer.files
// Handle directories in Chrome using the proprietary FileSystem API
var items = Array.from(e.dataTransfer.items).filter(function (item) {
const items = Array.from(e.dataTransfer.items).filter(item => {
return item.kind === 'file'

@@ -133,7 +133,7 @@ })

parallel(items.map(function (item) {
return function (cb) {
parallel(items.map(item => {
return cb => {
processEntry(item.webkitGetAsEntry(), cb)
}
}), function (err, results) {
}), (err, results) => {
// This catches permission errors with file:// in Chrome. This should never

@@ -143,9 +143,9 @@ // throw in production code, so the user does not need to use try-catch.

var entries = results.flat()
const entries = results.flat()
var files = entries.filter(function (item) {
const files = entries.filter(item => {
return item.isFile
})
var directories = entries.filter(function (item) {
const directories = entries.filter(item => {
return item.isDirectory

@@ -167,6 +167,6 @@ })

function processEntry (entry, cb) {
var entries = []
let entries = []
if (entry.isFile) {
entry.file(function (file) {
entry.file(file => {
file.fullPath = entry.fullPath // preserve pathing for consumer

@@ -176,12 +176,12 @@ file.isFile = true

cb(null, file)
}, function (err) {
}, err => {
cb(err)
})
} else if (entry.isDirectory) {
var reader = entry.createReader()
readEntries()
const reader = entry.createReader()
readEntries(reader)
}
function readEntries () {
reader.readEntries(function (entries_) {
function readEntries (reader) {
reader.readEntries(entries_ => {
if (entries_.length > 0) {

@@ -197,7 +197,7 @@ entries = entries.concat(Array.from(entries_))

function doneEntries () {
parallel(entries.map(function (entry) {
return function (cb) {
parallel(entries.map(entry => {
return cb => {
processEntry(entry, cb)
}
}), function (err, results) {
}), (err, results) => {
if (err) {

@@ -204,0 +204,0 @@ cb(err)

{
"name": "drag-drop",
"description": "HTML5 drag & drop for humans",
"version": "5.0.0",
"version": "5.0.1",
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)",

@@ -6,0 +6,0 @@ "bugs": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc