-
Notifications
You must be signed in to change notification settings - Fork 26.1k
fix(core): guard usages of performance.mark
#52505
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
Conversation
a7c4e21 to
99e36d4
Compare
performance.markperformance.mark
99e36d4 to
bcef20d
Compare
More context in angular/angular#52505
More context in angular/angular#52505 (cherry picked from commit 5f14bf3)
More context in angular/angular#52505
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.
LGTM overall, but not sure about the lint rule
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker. This commit, updates the usage to a safer variant.
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.
Reviewed-for: global-approvers
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker.
8e5cae1 to
fd2a147
Compare
|
This PR was merged into the repository by commit d4bd3f1. |
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker. PR Close #52505
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker. This commit, updates the usage to a safer variant. PR Close #52505
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker. PR Close #52505
| markName: string, | ||
| markOptions?: PerformanceMarkOptions|undefined, | ||
| ): PerformanceMark|undefined { | ||
| return performance?.mark?.(markName, markOptions); |
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.
Sorry for the late comment. I'm wondering if we should make it even safer by checking if the performance is defined as a global first, i.e.:
return typeof performance !== 'undefined' ? performance.mark?.(markName, markOptions) : undefined;
@alan-agius4 WDYT?
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.
So far I didn’t encountered any occurrences that requires such check.
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker. This commit, updates the usage to a safer variant. PR Close angular#52505
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker. PR Close angular#52505
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker. This commit, updates the usage to a safer variant. PR Close angular#52505
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker. PR Close angular#52505
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker. This commit, updates the usage to a safer variant. PR Close angular#52505
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker. PR Close angular#52505
While
performance.markis available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker.This commit, updates the usage to a safer variant.