react-dropzone
Advanced tools
Comparing version 3.5.0 to 3.5.1
@@ -0,1 +1,5 @@ | ||
# 3.5.1 | ||
* Fixed: `onDrop` is now called only if all files are passing the `accept` check. [#173](https://github.com/okonet/react-dropzone/pull/173) Closes #138, #145 | ||
# 3.5.0 | ||
@@ -2,0 +6,0 @@ |
@@ -196,7 +196,7 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
if (this.props.onDrop) { | ||
this.props.onDrop.call(this, files, e); | ||
} | ||
if (this.allFilesAccepted(files)) { | ||
if (this.props.onDrop) { | ||
this.props.onDrop.call(this, files, e); | ||
} | ||
if (this.allFilesAccepted(files)) { | ||
if (this.props.onDropAccepted) { | ||
@@ -363,3 +363,3 @@ this.props.onDropAccepted.call(this, files, e); | ||
inputProps: _react2.default.PropTypes.object, // Pass additional attributes to the <file type="input"/> tag | ||
inputProps: _react2.default.PropTypes.object, // Pass additional attributes to the <input type="file"/> tag | ||
multiple: _react2.default.PropTypes.bool, // Allow dropping multiple files | ||
@@ -366,0 +366,0 @@ accept: _react2.default.PropTypes.string, // Allow specific types of files. See https://github.com/okonet/attr-accept for more information |
{ | ||
"name": "react-dropzone", | ||
"version": "3.5.0", | ||
"version": "3.5.1", | ||
"description": "Simple HTML5 drag-drop zone with React.js", | ||
@@ -11,3 +11,3 @@ "main": "dist/index.js", | ||
"release": "npmpub", | ||
"test": "mocha --require ./mocha-environment.js ./src/test.js", | ||
"test": "npm run eslint && mocha --require ./mocha-environment.js ./src/test.js", | ||
"test:build": "NODE_ENV=production npm run build && npm run test", | ||
@@ -32,3 +32,3 @@ "eslint": "eslint ./src ./*.js", | ||
"type": "git", | ||
"url": "git@github.com:okonet/react-dropzone.git" | ||
"url": "git+https://github.com/okonet/react-dropzone.git" | ||
}, | ||
@@ -35,0 +35,0 @@ "bugs": { |
@@ -106,7 +106,7 @@ /* eslint prefer-template: 0 */ | ||
if (this.props.onDrop) { | ||
this.props.onDrop.call(this, files, e); | ||
} | ||
if (this.allFilesAccepted(files)) { | ||
if (this.props.onDrop) { | ||
this.props.onDrop.call(this, files, e); | ||
} | ||
if (this.allFilesAccepted(files)) { | ||
if (this.props.onDropAccepted) { | ||
@@ -266,3 +266,3 @@ this.props.onDropAccepted.call(this, files, e); | ||
inputProps: React.PropTypes.object, // Pass additional attributes to the <file type="input"/> tag | ||
inputProps: React.PropTypes.object, // Pass additional attributes to the <input type="file"/> tag | ||
multiple: React.PropTypes.bool, // Allow dropping multiple files | ||
@@ -269,0 +269,0 @@ accept: React.PropTypes.string, // Allow specific types of files. See https://github.com/okonet/attr-accept for more information |
@@ -16,3 +16,4 @@ /* eslint no-unused-expressions: 0 */ | ||
name: 'file1.pdf', | ||
size: 1111 | ||
size: 1111, | ||
type: 'application/pdf' | ||
}]; | ||
@@ -118,2 +119,52 @@ }); | ||
it('applies the accept prop to the dropped files', () => { | ||
const images = [{ | ||
name: 'cats.gif', | ||
size: 1234, | ||
type: 'image/gif' | ||
}, { | ||
name: 'dogs.jpg', | ||
size: 2345, | ||
type: 'image/jpeg' | ||
}]; | ||
const dropSpy = spy(); | ||
const dropzone = TestUtils.renderIntoDocument( | ||
<Dropzone onDrop={dropSpy} accept="image/*"> | ||
<div className="dropzone-content">some content</div> | ||
</Dropzone> | ||
); | ||
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content'); | ||
TestUtils.Simulate.drop(content, { dataTransfer: { files } }); | ||
expect(dropSpy.callCount).to.equal(0); | ||
TestUtils.Simulate.drop(content, { dataTransfer: { files: images } }); | ||
expect(dropSpy.callCount).to.equal(1); | ||
expect(dropSpy.firstCall.args[0]).to.have.length(2); | ||
}); | ||
it('accepts all dropped files when no accept prop is specified', () => { | ||
const images = [{ | ||
name: 'cats.gif', | ||
size: 1234, | ||
type: 'image/gif' | ||
}, { | ||
name: 'dogs.jpg', | ||
size: 2345, | ||
type: 'image/jpeg' | ||
}]; | ||
const dropSpy = spy(); | ||
const dropzone = TestUtils.renderIntoDocument( | ||
<Dropzone onDrop={dropSpy}> | ||
<div className="dropzone-content">some content</div> | ||
</Dropzone> | ||
); | ||
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content'); | ||
TestUtils.Simulate.drop(content, { dataTransfer: { files } }); | ||
expect(dropSpy.callCount).to.equal(1); | ||
TestUtils.Simulate.drop(content, { dataTransfer: { files: images } }); | ||
expect(dropSpy.callCount).to.equal(2); | ||
expect(dropSpy.secondCall.args[0]).to.have.length(2); | ||
}); | ||
it('applies the name prop to the child input', () => { | ||
@@ -120,0 +171,0 @@ const component = TestUtils.renderIntoDocument( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
121591
28
797
0
148
3