-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add additional optional chaining to prevent import errors when chrome api not available #8432
Conversation
…hrome api is not available
No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack. Do not edit this comment manually. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8432 +/- ##
==========================================
- Coverage 73.47% 73.41% -0.06%
==========================================
Files 1334 1352 +18
Lines 41259 41520 +261
Branches 7686 7773 +87
==========================================
+ Hits 30316 30483 +167
- Misses 10943 11037 +94 ☔ View full report in Codecov by Sentry. |
if (!chrome.runtime?.getManifest) { | ||
return false; | ||
} | ||
|
||
// Use optional chaining in case the chrome runtime is not available: | ||
// https://github.com/pixiebrix/pixiebrix-extension/issues/8273 | ||
return chrome.runtime.getManifest().manifest_version === 3; |
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'm pretty sure you can also just keep chaining the null-safe access as before, if you want:
if (!chrome.runtime?.getManifest) { | |
return false; | |
} | |
// Use optional chaining in case the chrome runtime is not available: | |
// https://github.com/pixiebrix/pixiebrix-extension/issues/8273 | |
return chrome.runtime.getManifest().manifest_version === 3; | |
// Use optional chaining in case the chrome runtime is not available: | |
// https://github.com/pixiebrix/pixiebrix-extension/issues/8273 | |
return chrome.runtime?.getManifest?.()?.manifest_version === 3; |
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.
Thanks ben, I actually didn't remember that you could put the double parentheses after the null operator.
Playwright test results - MV2Details Open report ↗︎ Flaky testsedge › tests/extensionConsoleActivation.spec.ts › can activate a mod with a database Skipped testschrome › tests/extensionConsoleActivation.spec.ts › can activate a mod with built-in integration |
Playwright test results - MV3Details Open report ↗︎ Flaky testschrome › tests/regressions/doNotCloseSidebarOnPageEditorSave.spec.ts › #8104: Do not automatically close the sidebar when saving in the Page Editor |
What does this PR do?
Discussion
Checklist