Socket
Socket
Sign inDemoInstall

react-dropzone

Package Overview
Dependencies
Maintainers
2
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dropzone - npm Package Compare versions

Comparing version 8.0.4 to 8.1.0

14

dist/es/index.js

@@ -21,3 +21,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

import PropTypes from 'prop-types';
import { isDragDataWithFiles, supportMultiple, fileAccepted, allFilesAccepted, fileMatchSize, onDocumentDragOver, getDataTransferItems as defaultGetDataTransferItem, isIeOrEdge, composeEventHandlers } from './utils';
import { isDragDataWithFiles, supportMultiple, fileAccepted, allFilesAccepted, fileMatchSize, onDocumentDragOver, getDataTransferItems as defaultGetDataTransferItem, isIeOrEdge, composeEventHandlers, isPropagationStopped, isDefaultPrevented } from './utils';

@@ -66,3 +66,3 @@ var Dropzone = function (_React$Component) {

Promise.resolve(_this.props.getDataTransferItems(evt)).then(function (draggedFiles) {
if (evt.isPropagationStopped()) {
if (isPropagationStopped(evt)) {
return;

@@ -151,3 +151,3 @@ }

if (evt.isPropagationStopped()) {
if (isPropagationStopped(evt)) {
return;

@@ -201,3 +201,3 @@ }

// the onClick listener, open the file dialog
if (!disableClick && !evt.isDefaultPrevented()) {
if (!disableClick && !isDefaultPrevented(evt)) {
evt.stopPropagation();

@@ -244,3 +244,3 @@

}
if (!evt.isDefaultPrevented()) {
if (!isDefaultPrevented(evt)) {
_this.setState({ isFocused: true });

@@ -254,3 +254,3 @@ }

}
if (!evt.isDefaultPrevented()) {
if (!isDefaultPrevented(evt)) {
_this.setState({ isFocused: false });

@@ -269,3 +269,3 @@ }

if (!evt.isDefaultPrevented() && (evt.keyCode === 32 || evt.keyCode === 13)) {
if (!isDefaultPrevented(evt) && (evt.keyCode === 32 || evt.keyCode === 13)) {
evt.preventDefault();

@@ -272,0 +272,0 @@ _this.open();

@@ -45,2 +45,26 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

// React's synthetic events has evt.isPropagationStopped,
// but to remain compatibility with other libs (Preact) fall back
// to check evt.cancelBubble
export function isPropagationStopped(evt) {
if (typeof evt.isPropagationStopped === 'function') {
return evt.isPropagationStopped();
} else if (typeof evt.cancelBubble !== 'undefined') {
return evt.cancelBubble;
}
return false;
}
// React's synthetic events has evt.isDefaultPrevented,
// but to remain compatibility with other libs (Preact) first
// check evt.defaultPrevented
export function isDefaultPrevented(evt) {
if (typeof evt.defaultPrevented !== 'undefined') {
return evt.defaultPrevented;
} else if (typeof evt.isDefaultPrevented === 'function') {
return evt.isDefaultPrevented();
}
return false;
}
export function isDragDataWithFiles(evt) {

@@ -47,0 +71,0 @@ if (!evt.dataTransfer) {

@@ -151,3 +151,3 @@ {

},
"version": "8.0.4",
"version": "8.1.0",
"engines": {

@@ -154,0 +154,0 @@ "node": ">= 6"

@@ -14,3 +14,5 @@ /* eslint prefer-template: 0 */

isIeOrEdge,
composeEventHandlers
composeEventHandlers,
isPropagationStopped,
isDefaultPrevented
} from './utils'

@@ -77,3 +79,3 @@

Promise.resolve(this.props.getDataTransferItems(evt)).then(draggedFiles => {
if (evt.isPropagationStopped()) {
if (isPropagationStopped(evt)) {
return

@@ -166,3 +168,3 @@ }

if (evt.isPropagationStopped()) {
if (isPropagationStopped(evt)) {
return

@@ -218,3 +220,3 @@ }

// the onClick listener, open the file dialog
if (!disableClick && !evt.isDefaultPrevented()) {
if (!disableClick && !isDefaultPrevented(evt)) {
evt.stopPropagation()

@@ -264,3 +266,3 @@

}
if (!evt.isDefaultPrevented()) {
if (!isDefaultPrevented(evt)) {
this.setState({ isFocused: true })

@@ -275,3 +277,3 @@ }

}
if (!evt.isDefaultPrevented()) {
if (!isDefaultPrevented(evt)) {
this.setState({ isFocused: false })

@@ -291,3 +293,3 @@ }

if (!evt.isDefaultPrevented() && (evt.keyCode === 32 || evt.keyCode === 13)) {
if (!isDefaultPrevented(evt) && (evt.keyCode === 32 || evt.keyCode === 13)) {
evt.preventDefault()

@@ -294,0 +296,0 @@ this.open()

@@ -44,2 +44,26 @@ import accepts from 'attr-accept'

// React's synthetic events has evt.isPropagationStopped,
// but to remain compatibility with other libs (Preact) fall back
// to check evt.cancelBubble
export function isPropagationStopped(evt) {
if (typeof evt.isPropagationStopped === 'function') {
return evt.isPropagationStopped()
} else if (typeof evt.cancelBubble !== 'undefined') {
return evt.cancelBubble
}
return false
}
// React's synthetic events has evt.isDefaultPrevented,
// but to remain compatibility with other libs (Preact) first
// check evt.defaultPrevented
export function isDefaultPrevented(evt) {
if (typeof evt.defaultPrevented !== 'undefined') {
return evt.defaultPrevented
} else if (typeof evt.isDefaultPrevented === 'function') {
return evt.isDefaultPrevented()
}
return false
}
export function isDragDataWithFiles(evt) {

@@ -46,0 +70,0 @@ if (!evt.dataTransfer) {

@@ -6,3 +6,5 @@ import {

isDragDataWithFiles,
composeEventHandlers
composeEventHandlers,
isPropagationStopped,
isDefaultPrevented
} from './'

@@ -143,2 +145,34 @@

describe('isPropagationStopped()', () => {
const trueFn = jest.fn(() => true)
it('should return result of isPropagationStopped() if isPropagationStopped exists', () => {
expect(isPropagationStopped({ isPropagationStopped: trueFn })).toBe(true)
})
it('should return value of cancelBubble if isPropagationStopped doesnt exist and cancelBubble exists', () => {
expect(isPropagationStopped({ cancelBubble: true })).toBe(true)
})
it('should return false if isPropagationStopped and cancelBubble are missing', () => {
expect(isPropagationStopped({})).toBe(false)
})
})
describe('isDefaultPrevented()', () => {
const trueFn = jest.fn(() => true)
it('should return value of defaultPrevented if defaultPrevented exists', () => {
expect(isDefaultPrevented({ defaultPrevented: true })).toBe(true)
})
it('should return result of isDefaultPrevented() if isDefaultPrevented exists and defaultPrevented is missing', () => {
expect(isDefaultPrevented({ isDefaultPrevented: trueFn })).toBe(true)
})
it('should return false if isDefaultPrevented and defaultPrevented are missing', () => {
expect(isDefaultPrevented({})).toBe(false)
})
})
describe('isDragDataWithFiles()', () => {

@@ -145,0 +179,0 @@ it('should return true if every dragged type is a file', () => {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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