Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/web/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ export const routes: Routes = [
canActivate: [developmentOnly],
title: `Debug Components | ${PAGE_TITLE}`,
},
{
path: 'iframe',
loadComponent: () =>
import('./features/debug/iframe-debug-page.component').then(
(m) => m.IframeDebugPageComponent
),
canActivate: [developmentOnly],
title: `Debug iframe | ${PAGE_TITLE}`,
},
],
},
],
Expand Down
20 changes: 20 additions & 0 deletions app/web/src/app/features/debug/iframe-debug-page.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'
import { DomSanitizer } from '@angular/platform-browser'

@Component({
selector: 'da-iframe-debug-page',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="size-full border-1">
<iframe
[src]="iframeSrc"
class="size-full"
></iframe>
</div>
`,
})
export class IframeDebugPageComponent {
private readonly domSanitizer = inject(DomSanitizer)
protected readonly iframeSrc =
this.domSanitizer.bypassSecurityTrustResourceUrl(window.location.origin)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Directly accessing the global window object is discouraged as it can cause issues with server-side rendering (SSR) where window is not defined. You can use globalThis along with optional chaining (?.) and nullish coalescing (??) to safely access window.location.origin only when it's available, providing an empty string as a fallback. This makes the code more robust and platform-independent.

Suggested change
this.domSanitizer.bypassSecurityTrustResourceUrl(window.location.origin)
this.domSanitizer.bypassSecurityTrustResourceUrl(globalThis.window?.location.origin ?? '')

}
Comment on lines +16 to +20
5 changes: 4 additions & 1 deletion app/web/src/app/features/kazumi/layout/kazumi-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import { RouterOutlet } from '@angular/router'
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [RouterOutlet],
template: `
<div class="container mx-auto px-6 py-4">
<div class="container h-full mx-auto px-6 py-4">
<main class="h-full">
<router-outlet />
</main>
</div>
`,
host: {
class: 'block h-full',
},
})
export class KazumiLayout {}
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ export class AppSidebar {
label: 'Components',
icon: 'toolbar',
},
{
path: '/debug/iframe',
label: 'iframe Debug',
icon: 'pip',
},
],
},
]),
Expand Down
Loading