Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c309487f
Commit
c309487f
authored
Nov 18, 2019
by
Fabio Huser
Committed by
Phil Hughes
Nov 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(dropzone): prevent dropzone exception if target element missing
parent
71953508
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
37 deletions
+56
-37
app/assets/javascripts/dropzone_input.js
app/assets/javascripts/dropzone_input.js
+1
-1
changelogs/unreleased/fix-dropzone-no-element-exception.yml
changelogs/unreleased/fix-dropzone-no-element-exception.yml
+5
-0
spec/javascripts/dropzone_input_spec.js
spec/javascripts/dropzone_input_spec.js
+50
-36
No files found.
app/assets/javascripts/dropzone_input.js
View file @
c309487f
...
...
@@ -290,5 +290,5 @@ export default function dropzoneInput(form) {
formTextarea
.
focus
();
});
return
Dropzone
.
forElement
(
$formDropzone
.
get
(
0
))
;
return
$formDropzone
.
get
(
0
)
?
Dropzone
.
forElement
(
$formDropzone
.
get
(
0
))
:
null
;
}
changelogs/unreleased/fix-dropzone-no-element-exception.yml
0 → 100644
View file @
c309487f
---
title
:
Prevent Dropzone.js initialisation error by checking target element existence
merge_request
:
20256
author
:
Fabio Huser
type
:
fixed
spec/javascripts/dropzone_input_spec.js
View file @
c309487f
...
...
@@ -13,6 +13,19 @@ const TEMPLATE = `<form class="gfm-form" data-uploads-path="${TEST_UPLOAD_PATH}"
</form>`
;
describe
(
'
dropzone_input
'
,
()
=>
{
it
(
'
returns null when failed to initialize
'
,
()
=>
{
const
dropzone
=
dropzoneInput
(
$
(
'
<form class="gfm-form"></form>
'
));
expect
(
dropzone
).
toBeNull
();
});
it
(
'
returns valid dropzone when successfully initialize
'
,
()
=>
{
const
dropzone
=
dropzoneInput
(
$
(
TEMPLATE
));
expect
(
dropzone
.
version
).
toBeTruthy
();
});
describe
(
'
shows error message
'
,
()
=>
{
let
form
;
let
dropzone
;
let
xhr
;
...
...
@@ -32,7 +45,7 @@ describe('dropzone_input', () => {
window
.
XMLHttpRequest
=
oldXMLHttpRequest
;
});
it
(
'
shows error message,
when AJAX fails with json
'
,
()
=>
{
it
(
'
when AJAX fails with json
'
,
()
=>
{
xhr
=
{
...
xhr
,
statusCode
:
400
,
...
...
@@ -48,7 +61,7 @@ describe('dropzone_input', () => {
expect
(
form
.
find
(
'
.uploading-error-message
'
).
text
()).
toEqual
(
TEST_ERROR_MESSAGE
);
});
it
(
'
shows error message,
when AJAX fails with text
'
,
()
=>
{
it
(
'
when AJAX fails with text
'
,
()
=>
{
xhr
=
{
...
xhr
,
statusCode
:
400
,
...
...
@@ -63,4 +76,5 @@ describe('dropzone_input', () => {
expect
(
form
.
find
(
'
.uploading-error-message
'
).
text
()).
toEqual
(
TEST_ERROR_MESSAGE
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment