Skip to content

Fix global is not defined#174

Merged
f-fl0 merged 7 commits intomasterfrom
bug-fix-global-not-defined
Oct 5, 2022
Merged

Fix global is not defined#174
f-fl0 merged 7 commits intomasterfrom
bug-fix-global-not-defined

Conversation

@f-fl0
Copy link
Contributor

@f-fl0 f-fl0 commented Oct 4, 2022

I ran into the following error when trying to accessing pcdeditor at http://localhost:8080/ after running make. Renaming global to globalThis seems to solve the issue.

Screenshot from 2022-10-04 15-57-05

@codecov
Copy link

codecov bot commented Oct 4, 2022

Codecov Report

Base: 38.49% // Head: 38.49% // No change to project coverage 👍

Coverage data is based on head (71e460b) compared to base (e631d3c).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #174   +/-   ##
=======================================
  Coverage   38.49%   38.49%           
=======================================
  Files           8        8           
  Lines        1626     1626           
=======================================
  Hits          626      626           
  Misses        964      964           
  Partials       36       36           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@f-fl0 f-fl0 requested a review from at-wat October 4, 2022 07:29
Copy link
Member

@at-wat at-wat left a comment

Choose a reason for hiding this comment

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

It seems depending on Go version.
I think we need to fallback to global.* if globalThis.* is not available.

@f-fl0 f-fl0 requested a review from at-wat October 5, 2022 05:04
Fix if/else formatting

Co-authored-by: Atsushi Watanabe <atsushi.w@ieee.org>
pcdeditor.js Outdated
go.run(instance)
}
if (typeof global === 'undefined' || typeof global.Go === 'undefined') {
if (typeof globalThis === 'undefined' || typeof globalThis.Go === 'undefined') {
Copy link
Member

Choose a reason for hiding this comment

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

I think this condition should also handle global.Go.

Co-authored-by: Atsushi Watanabe <atsushi.w@ieee.org>
pcdeditor.js Outdated
}
if (typeof global === 'undefined' || typeof global.Go === 'undefined') {
if ((typeof globalThis === 'undefined' || typeof globalThis.Go === 'undefined') &&
(typeof global === 'undefined' || typeof global.Go === 'undefined') {
Copy link

Choose a reason for hiding this comment

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

🚫 [eslint] reported by reviewdog 🐶
Parsing error: ')' expected.

pcdeditor.js Outdated
})
.then((yamlBlob) => {
const img = new global.Image()
const img = new globalThis.Image()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const img = new globalThis.Image()
const img = new Image()

@f-fl0 f-fl0 requested a review from at-wat October 5, 2022 08:38
Copy link
Member

@at-wat at-wat left a comment

Choose a reason for hiding this comment

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

LGTM

@f-fl0 f-fl0 merged commit 40783db into master Oct 5, 2022
@f-fl0 f-fl0 deleted the bug-fix-global-not-defined branch October 5, 2022 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants