Fix the diff viewer JS with modern babel.

Review Request #12102 — Created March 6, 2022 and submitted — Latest diff uploaded

Information

Review Board
release-5.0.x

Reviewers

This fixes an error when loading the diff viewer on release-5.0.x (and
master). Devtools were showing an error that the DiffViewerPage
constructor wasn't a constructor. The issue here seems to be a change in
the way that the newer babel deals with function shorthands inside of an
object. Whereas before it was translating constructor() {...} to
constructor: function constructor() {...}, it now leaves them as-is.
In most cases this works fine, but it seems like browsers are treating
the constructor name specially (since it's a reserved word and used
for classes). Explicitly using the older object attribute syntax fixes
this.

Created a review request with a diff and was able to successfully load
the diff viewer page.

Diff Revision 1 (Latest)

Commits

First Last Summary ID Author
Fix the diff viewer JS with modern babel.
This fixes an error when loading the diff viewer on release-5.0.x (and master). Devtools were showing an error that the `DiffViewerPage` constructor wasn't a constructor. The issue here seems to be a change in the way that the newer babel deals with function shorthands inside of an object. Whereas before it was translating `constructor() {...}` to `constructor: function constructor() {...}`, it now leaves them as-is. In most cases this works fine, but it seems like browsers are treating the `constructor` name specially (since it's a reserved word and used for classes). Explicitly using the older object attribute syntax fixes this. Testing Done: Created a review request with a diff and was able to successfully load the diff viewer page.
f38281b289888ace814363e0b562102270261d9f David Trowbridge
reviewboard/static/rb/js/pages/models/diffViewerPageModel.es6.js
Loading...