feat: Extend FileReader to conform with EventTarget interface #449
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Platforms affected
All.
Motivation and Context
Currently,
cordova-plugin-file'sFileReaderdoesn't correctly implement theEventTargetinterface. What works are listeners attached viaon[event]properties, likeonloadend. What doesn't work are listeners attached viaaddEventListener('loadend', ...), they are simply never called.Some libraries depend upon
FileReaderto implement theEventTargetinterface. One such library is the Elm File package, it attaches events toFileReaderviaaddEventListener('loadend', ...)(see https://github.com/elm/file/blob/1.0.5/src/Elm/Kernel/File.js#L155).Description
The implmentations of
FileReaderwas changed so that events attached viaEventTarget'saddEventListener()method are called just like the listeners attached viaon[event]properties.Testing
This change has been in our Cordova app in production for a while, without negative effects.
Checklist
(platform)if this change only applies to one platform (e.g.(android))