@@ -3,6 +3,7 @@ import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
3
3
import { DOCUMENT } from '@angular/common' ;
4
4
import { HttpClient } from '@angular/common/http' ;
5
5
import { Observable , Subject } from 'rxjs' ;
6
+ import { PlatformUtil } from '../core/utils' ;
6
7
7
8
/**
8
9
* Event emitted when a SVG icon is loaded through
@@ -48,14 +49,19 @@ export class IgxIconService {
48
49
private _familyAliases = new Map < string , string > ( ) ;
49
50
private _cachedSvgIcons = new Map < string , Map < string , SafeHtml > > ( ) ;
50
51
private _iconLoaded = new Subject < IgxIconLoadedEvent > ( ) ;
51
- private _domParser = new DOMParser ( ) ;
52
+ private _domParser : DOMParser ;
52
53
53
54
constructor (
54
55
@Optional ( ) private _sanitizer : DomSanitizer ,
55
56
@Optional ( ) private _httpClient : HttpClient ,
56
- @Optional ( ) @Inject ( DOCUMENT ) private _document : any
57
+ @Optional ( ) private _platformUtil : PlatformUtil ,
58
+ @Optional ( ) @Inject ( DOCUMENT ) private _document : any ,
57
59
) {
58
60
this . iconLoaded = this . _iconLoaded . asObservable ( ) ;
61
+
62
+ if ( this . _platformUtil . isBrowser ) {
63
+ this . _domParser = new DOMParser ( ) ;
64
+ }
59
65
}
60
66
61
67
/**
@@ -188,7 +194,7 @@ export class IgxIconService {
188
194
private cacheSvgIcon ( name : string , value : string , family = this . _family , stripMeta : boolean ) {
189
195
family = ! ! family ? family : this . _family ;
190
196
191
- if ( name && value ) {
197
+ if ( this . _platformUtil . isBrowser && name && value ) {
192
198
const doc = this . _domParser . parseFromString ( value , 'image/svg+xml' ) ;
193
199
const svg = doc . querySelector ( 'svg' ) as SVGElement ;
194
200
0 commit comments