From e3fcbb7d606776c45976592c2cf83e63e16eb2e9 Mon Sep 17 00:00:00 2001 From: Shipra Gupta Date: Fri, 7 Nov 2025 18:53:10 -0800 Subject: [PATCH] fix(overlay): add null checks for window.__swc.warn in test environments (cherry picked from commit a8163fd9e81c787a4935951c6c26ea8822ce525e) --- 1st-gen/packages/overlay/src/slottable-request-directive.ts | 2 +- 1st-gen/packages/overlay/src/slottable-request-event.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/1st-gen/packages/overlay/src/slottable-request-directive.ts b/1st-gen/packages/overlay/src/slottable-request-directive.ts index 965a9e81bd3..ed4f0920874 100644 --- a/1st-gen/packages/overlay/src/slottable-request-directive.ts +++ b/1st-gen/packages/overlay/src/slottable-request-directive.ts @@ -74,7 +74,7 @@ export class SlottableRequestDirective extends AsyncDirective { { signal } ); - if (window.__swc.DEBUG) { + if (window.__swc?.DEBUG && window.__swc?.warn) { window.__swc.warn( undefined, `⚠️ WARNING ⚠️ : The Overlay Trigger Directive is experimental and there is no guarantees behind its usage in an application!! Its API and presence within the library could be changed at anytime. See "sp-overlay" or "Overlay.open()" for a stable API for overlaying content on your application.`, diff --git a/1st-gen/packages/overlay/src/slottable-request-event.ts b/1st-gen/packages/overlay/src/slottable-request-event.ts index 6d6caa2050c..3f598742c8c 100644 --- a/1st-gen/packages/overlay/src/slottable-request-event.ts +++ b/1st-gen/packages/overlay/src/slottable-request-event.ts @@ -23,7 +23,7 @@ export class SlottableRequestEvent extends Event { this.name = name; this.data = data; this.slotName = key !== undefined ? `${name}.${key}` : name; - if (window.__swc.DEBUG) { + if (window.__swc?.DEBUG && window.__swc?.warn) { window.__swc.warn( undefined, `⚠️ WARNING ⚠️ : \`slottable-request\` events are experimental and there is no guarantees behind usage of them in an application!! Their shape and presence within the library could be changed at anytime.