-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert the attachments/outline view to ES6 syntax #8302
Convert the attachments/outline view to ES6 syntax #8302
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've not had time to test the PR yet, but I'm adding a couple of small comments/questions based on a cursory look at the diff.
web/pdf_attachment_viewer.js
Outdated
PDFAttachmentViewer.prototype = { | ||
reset: function PDFAttachmentViewer_reset(keepRenderedCapability) { | ||
this.attachments = null; | ||
reset(keepRenderedCapability) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: reset(keepRenderedCapability = false) {
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the new commit.
web/pdf_attachment_viewer.js
Outdated
*/ | ||
_bindPdfLink(button, content, filename) { | ||
var blobUrl; | ||
button.onclick = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Unless I'm missing something, I don't think that you need an arrow function here (no this
in the function scope)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the new commit.
web/pdf_attachment_viewer.js
Outdated
return; | ||
} | ||
|
||
var names = Object.keys(attachments).sort((a, b) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Unless I'm missing something, I don't think that you need an arrow function here (no this
in the function scope)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the new commit.
web/pdf_attachment_viewer.js
Outdated
/** | ||
* @param {PDFAttachmentViewerRenderParameters} params | ||
*/ | ||
render(params = Object.create(null)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a matter of personal preference, but to me this feels overly verbose, and I think that just render(params = {}) {
would suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the new commit.
web/pdf_outline_viewer.js
Outdated
/** | ||
* @param {PDFOutlineViewerRenderParameters} params | ||
*/ | ||
render(params = Object.create(null)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a matter of personal preference, but to me this feels overly verbose, and I think that just render(params = {}) {
would suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the new commit.
9681ec5
to
0fada29
Compare
/botio-linux preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could now become const
instead: https://github.com/mozilla/pdf.js/blob/master/web/pdf_outline_viewer.js#L20.
@timvandermeij Please note that the following is not a criticism of your nice work in this patch, transitioning more /web
code to proper classes!
I'm simply interested in your thoughts on this matter, and whether you think we should try to avoid using e
as an identifier?
One thing that I've been guilty of myself from time to time, is to use e
as a variable/argument name.
However, I'm beginning to think that using one-character names like this isn't really conducive to readability of the code.
Particularly in the case of the e
shorthand-name, unless you look at the code, there can be some confusion as to what it represents. Looking at our code-base, it seems that it can be shorthand for either error
, exception
, or event
, depending on the context.
I see why one might not, depending on the situation, always want to spell out full names. However, something like err
, ex
, or evt
(for the cases above) might at least help readability somewhat!?
I don't like one-character variable names in general, but for some reason |
0fada29
to
9352017
Compare
I have updated the patch to use |
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/873061191c1e8d0/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/873061191c1e8d0/output.txt Total script time: 3.24 mins Published |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you for doing this!
…tline Convert the attachments/outline view to ES6 syntax
Easier reviewing with https://github.com/mozilla/pdf.js/pull/8302/files?w=1.