Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Call target.onload() only when defined #2056

Merged
merged 1 commit into from
Oct 13, 2018

Conversation

Javarome
Copy link
Contributor

@Javarome Javarome commented Oct 5, 2018

Brief description of the changes

This PR checks that the onload function is defined before calling it. This removes the Uncaught TypeError: target.onload is not a function console error while img preview.

What browsers and operating systems have you tested these changes on?

Chrome 69.0.3497.100 on MacOS Sierra 10.13.6

Have you written unit tests? If not, explain why.

No, because the modified code is likely already tested.

This removes the "Uncaught TypeError: target.onload is not a function" console error while img preview
@singhjusraj
Copy link
Member

Hi @Javarome
When does the Uncaught TypeError: target.onload is not a function error actually comes?
If you could let me know the reproduction steps, I would like to see the error.

@singhjusraj singhjusraj self-assigned this Oct 11, 2018
@Javarome
Copy link
Contributor Author

Javarome commented Oct 11, 2018

Hi @SinghSukhdeep

I encountered it many times in my production code when using <img> for preview. I am unable to share it here, but another user has reported here with some sample code : #1882

A PR was rejected about it because it prevented calling onload when defined, whereas this current PR will avoid calling it only when undefined.

In any case such a change can only make the code more robust by avoiding failure when the callback is not defined (but still calling it when it is).

@singhjusraj
Copy link
Member

Okay sounds good. Will merge this and release with few other pending PRs

@singhjusraj singhjusraj merged commit 3465fff into FineUploader:master Oct 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants