Skip to content

Commit

Permalink
add logging to parser
Browse files Browse the repository at this point in the history
  • Loading branch information
danielleroux committed Feb 27, 2025
1 parent f43cad7 commit 1053f27
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/icon/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let parser: any = null;
export const errorSymbol =
"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'><path fill-rule='evenodd' d='M384,0 L384,384 L0,384 L0,0 L384,0 Z M192,207.085 L57.751,341.333 L326.248,341.333 L192,207.085 Z M42.666,57.751 L42.666,326.248 L176.915,192 L42.666,57.751 Z M341.333,57.751 L207.085,192 L341.333,326.248 L341.333,57.751 Z M326.248,42.666 L57.751,42.666 L192,176.915 L326.248,42.666 Z' transform='translate(64 64)'/></svg>";

export function parseSVGDataContent(content: string): string {
export function parseSVGDataContent(content: string, element?: HTMLElement): string {
if (typeof window['DOMParser'] === 'undefined') {
console.error('DOMParser not supported by your browser.');
return '';
Expand All @@ -21,7 +21,11 @@ export function parseSVGDataContent(content: string): string {
const svgElement = svgDocument.querySelector('svg') as HTMLElement;

if (!svgElement) {
console.error('No valid svg data provided');
if (element) {
console.error('No valid svg data provided', element);
} else {
console.error('No valid svg data provided');
}
return '';
}

Expand Down

0 comments on commit 1053f27

Please sign in to comment.