fix(): dont error

This commit is contained in:
Manu Mtz.-Almeida
2019-06-25 20:43:13 +02:00
parent 668aacae7e
commit 0320bf2926
3 changed files with 4 additions and 7 deletions
+1 -3
View File
@@ -119,10 +119,8 @@ export class Icon {
if (Build.isBrowser && this.isVisible) {
const url = getUrl(this);
if (url) {
getSvgContent(this.el.ownerDocument as any, url)
getSvgContent(url)
.then(svgContent => this.svgContent = svgContent);
} else {
console.error('icon was not resolved');
}
}
+2 -2
View File
@@ -4,7 +4,7 @@ import { validateContent } from './validate';
const requests = new Map<string, Promise<string>>();
export const getSvgContent = (doc: Document, url: string) => {
export const getSvgContent = (url: string) => {
// see if we already have a request for this url
let req = requests.get(url);
@@ -16,7 +16,7 @@ export const getSvgContent = (doc: Document, url: string) => {
}
return Promise.resolve(null);
}).then(svgContent => validateContent(doc, svgContent));
}).then(svgContent => validateContent(svgContent));
// cache for the same requests
requests.set(url, req);
+1 -2
View File
@@ -2,11 +2,10 @@ import { isStr } from './utils';
export const validateContent = (
doc: Document,
svgContent: string | null
) => {
if (svgContent) {
const div = doc.createElement('div');
const div = document.createElement('div');
div.innerHTML = svgContent;
// setup this way to ensure it works on our buddy IE