diff --git a/src/lib/icon/icon-registry.ts b/src/lib/icon/icon-registry.ts index 0b0ac8a5b4c7..1aeca0b5ba0c 100644 --- a/src/lib/icon/icon-registry.ts +++ b/src/lib/icon/icon-registry.ts @@ -110,8 +110,7 @@ export class MatIconRegistry { constructor( @Optional() private _httpClient: HttpClient, private _sanitizer: DomSanitizer, - @Optional() @Inject(DOCUMENT) document?: any) { - // TODO(crisbeto): make _document required next major release. + @Optional() @Inject(DOCUMENT) document: any) { this._document = document; } @@ -427,17 +426,15 @@ export class MatIconRegistry { * Creates a DOM element from the given SVG string. */ private _svgElementFromString(str: string): SVGElement { - if (this._document || typeof document !== 'undefined') { - const div = (this._document || document).createElement('DIV'); - div.innerHTML = str; - const svg = div.querySelector('svg') as SVGElement; - if (!svg) { - throw Error(' tag not found'); - } - return svg; + const div = this._document.createElement('DIV'); + div.innerHTML = str; + const svg = div.querySelector('svg') as SVGElement; + + if (!svg) { + throw Error(' tag not found'); } - throw new Error('MatIconRegistry could not resolve document.'); + return svg; } /**