Skip to content

refactor(icon): remove 6.0.0 deletion targets #10389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2018
Merged
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
19 changes: 8 additions & 11 deletions src/lib/icon/icon-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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('<svg> 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('<svg> tag not found');
}

throw new Error('MatIconRegistry could not resolve document.');
return svg;
}

/**
Expand Down