Skip to content

Commit

Permalink
fix(lib): use document token to access window
Browse files Browse the repository at this point in the history
Use DOCUMENT token for safe access of the window object on SSR
  • Loading branch information
ChristopherPHolder authored Dec 13, 2024
2 parents 34b5906 + 615b41a commit 2086651
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/ngx-fast-lib/src/lib/token/svg-load.strategy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { from, Observable, of, switchMap } from 'rxjs';
import { getZoneUnPatchedApi } from '../internal/get-zone-unpatched-api';
import { SvgLoadStrategy } from './svg-load.strategy.model';
import { Injectable } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { inject, Injectable } from '@angular/core';

@Injectable()
export class SvgLoadStrategyImpl implements SvgLoadStrategy {
fetch = getZoneUnPatchedApi('fetch', window as any);
document = inject(DOCUMENT);
fetch = getZoneUnPatchedApi('fetch', this.document.defaultView as any);

load(url$: Observable<string>): Observable<string> {
return url$.pipe(switchMap((url) => {
Expand Down

0 comments on commit 2086651

Please sign in to comment.