Skip to content

Commit 35e25f6

Browse files
arturovtkirjs
authored andcommitted
refactor(core): drop platform check in ImagePerformanceWarning (angular#59809)
Replaces `PLATFORM_ID` checks with `ngServerMode`. PR Close angular#59809
1 parent c513e5d commit 35e25f6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/core/src/image_performance_warning.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {IMAGE_CONFIG, ImageConfig, PLATFORM_ID} from './application/application_tokens';
9+
import {IMAGE_CONFIG, ImageConfig} from './application/application_tokens';
1010
import {Injectable} from './di';
1111
import {inject} from './di/injector_compatibility';
1212
import {formatRuntimeError, RuntimeErrorCode} from './errors';
@@ -27,12 +27,11 @@ export class ImagePerformanceWarning implements OnDestroy {
2727
private window: Window | null = null;
2828
private observer: PerformanceObserver | null = null;
2929
private options: ImageConfig = inject(IMAGE_CONFIG);
30-
private readonly isBrowser = inject(PLATFORM_ID) === 'browser';
3130
private lcpImageUrl?: string;
3231

3332
public start() {
3433
if (
35-
!this.isBrowser ||
34+
(typeof ngServerMode !== 'undefined' && ngServerMode) ||
3635
typeof PerformanceObserver === 'undefined' ||
3736
(this.options?.disableImageSizeWarning && this.options?.disableImageLazyLoadWarning)
3837
) {
@@ -41,7 +40,7 @@ export class ImagePerformanceWarning implements OnDestroy {
4140
this.observer = this.initPerformanceObserver();
4241
const doc = getDocument();
4342
const win = doc.defaultView;
44-
if (typeof win !== 'undefined') {
43+
if (win) {
4544
this.window = win;
4645
// Wait to avoid race conditions where LCP image triggers
4746
// load event before it's recorded by the performance observer

0 commit comments

Comments
 (0)