mirror of
https://github.com/ionic-team/ionicons.git
synced 2026-11-30 16:48:16 +01:00
fix(): dont error
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user