Skip to content
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

[Firefox addon] Convert the code to be ES6 friendly, in order to better agree with mozilla-central coding conventions (issue 7957) #7982

Merged
merged 1 commit into from
Jan 23, 2017

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Jan 22, 2017

Please note: ignoring whitespace changes is most likely necessary for the diff to be readable:
https://github.com/mozilla/pdf.js/pull/7982/files?w=1

This patch addresses all the current, in mozilla-central, linting failures in the addon. It should thus be possible to change the .eslintignore entry for PDF.js in mozilla-central from browser/extensions/pdfjs/** to browser/extensions/pdfjs/build/** and browser/extensions/pdfjs/web/** instead.
Note that we cannot, for backwards compatibility reason of the general PDF.js library, at this time make similar changes for files residing in the build and web directories in mozilla-central.

The main changes in this patch are that we now use classes instead of our previous "class-like" functions, and also use the more compact object shorthand notation.
A couple of functions were also converted to arrow functions, to reduced usages of bind(this) and var self = this.

One caveat with ES6 classes is that it's not (yet) possible to define private constants/helper functions within them, which is why the NetworkManagerClosure was kept to not change the visibility of those constant/functions.

Besides testing in Firefox Nightly 53, this patch has also been tested in Firefox ESR 45 and SeaMonkey 2.46.
However, I'd gladly welcome help with testing the patch more, to ensure that nothing has gone wrong during the refactoring.

Fixes the first bullet point of #7957 (comment).

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/15484d25e96f49b/output.txt

…er agree with mozilla-central coding conventions (issue 7957)

*Please note: ignoring whitespace changes is most likely necessary for the diff to be readable.*

This patch addresses all the current, in `mozilla-central`, linting failures in the addon. It should thus be possible to change the `.eslintignore` entry for PDF.js in `mozilla-central` from `browser/extensions/pdfjs/**` to `browser/extensions/pdfjs/build/**` and `browser/extensions/pdfjs/web/**` instead.
Note that we cannot, for backwards compatibility reason of the general PDF.js library, at this time make similar changes for files residing in the `build` and `web` directories in `mozilla-central`.

The main changes in this patch are that we now use [classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) instead of our previous "class-like" functions, and also use the more compact [object shorthand notation](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Object_initializer#New_notations_in_ECMAScript_2015).
A couple of functions were also converted to [arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions), to reduced usages of `bind(this)` and `var self = this`.

One caveat with ES6 classes is that it's not (yet) possible to define private constants/helper functions within them, which is why the `NetworkManagerClosure` was kept to not change the visibility of those constant/functions.

Besides testing in Firefox Nightly 53, this patch has also been tested in Firefox ESR 45 and SeaMonkey 2.46.
However, I'd gladly welcome help with testing the patch more, to ensure that nothing has gone wrong during the refactoring.

Fixes the first bullet point of issue 7957.
@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/15484d25e96f49b/output.txt

Total script time: 2.22 mins

Published

Copy link
Contributor

@yurydelendik yurydelendik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch.

@yurydelendik yurydelendik merged commit fd1affa into mozilla:master Jan 23, 2017
@Snuffleupagus Snuffleupagus deleted the addon-es6 branch January 23, 2017 16:16
@yurydelendik
Copy link
Contributor

/cc @rvandermeulen

@rvandermeulen
Copy link

Thanks for the heads-up, I'll make sure to update .eslintrc on the mozilla-central side on the next update!

movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
[Firefox addon] Convert the code to be ES6 friendly, in order to better agree with mozilla-central coding conventions (issue 7957)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants