Skip to content

Commit a8b574b

Browse files
crisbetojosephperrott
authored andcommitted
refactor(icon): remove 6.0.0 deletion targets (angular#10389)
Removes the `material/icon` deletion targets for 6.0.0. BREAKING CHANGES: * The `_document` parameter in the `MatIconRegistry` constructor is now required.
1 parent 865c8d3 commit a8b574b

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/lib/icon/icon-registry.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ export class MatIconRegistry {
110110
constructor(
111111
@Optional() private _httpClient: HttpClient,
112112
private _sanitizer: DomSanitizer,
113-
@Optional() @Inject(DOCUMENT) document?: any) {
114-
// TODO(crisbeto): make _document required next major release.
113+
@Optional() @Inject(DOCUMENT) document: any) {
115114
this._document = document;
116115
}
117116

@@ -427,17 +426,15 @@ export class MatIconRegistry {
427426
* Creates a DOM element from the given SVG string.
428427
*/
429428
private _svgElementFromString(str: string): SVGElement {
430-
if (this._document || typeof document !== 'undefined') {
431-
const div = (this._document || document).createElement('DIV');
432-
div.innerHTML = str;
433-
const svg = div.querySelector('svg') as SVGElement;
434-
if (!svg) {
435-
throw Error('<svg> tag not found');
436-
}
437-
return svg;
429+
const div = this._document.createElement('DIV');
430+
div.innerHTML = str;
431+
const svg = div.querySelector('svg') as SVGElement;
432+
433+
if (!svg) {
434+
throw Error('<svg> tag not found');
438435
}
439436

440-
throw new Error('MatIconRegistry could not resolve document.');
437+
return svg;
441438
}
442439

443440
/**

0 commit comments

Comments
 (0)