Modernize the FirefoxCom.request
method
#12801
Merged
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.
Please note: I've tested this patch in a local Firefox build, to ensure that I didn't break anything here :-)
Use the
once: true
option, rather than manually removing the "pdf.js.response" event listener inFirefoxCom.request
When this code was originally added, the
once
option didn't exist yet.Use
remove
, rather thanremoveChild
, when removing the temporaryText
nodes used inFirefoxCom
This is the "modern" way of removing a node from the DOM, which has the benefit of being a lot shorter and more concise.
Also, this patch removes the
return
statement from the "pdf.js.response" event listener, since it's alwaysundefined
, given that none of thecallback
-functions used here ever return anything (and don't need to either). Generally speaking, returning a value from an event listener isn't normally necessary either.Ensure that the "pdf.js.response" event listener, in
FirefoxCom.request
, actually applies to the currentText
nodeGiven that the event listener is registered on the document, there could in theory be more than one of these listeners present at any one time.
In practice this doesn't currently happen, since all of the
actions
invoked inPdfStreamConverter.jsm
are synchronous methods. However, there's no guarantee that this will always be the case, and it's easy enough to prevent any future issues here by simply registering the "pdf.js.response" event listener on theText
node instead. This works since, as can be seen inPdfStreamConverter.jsm
, the event is dispatched on the element itself rather than the document.