Skip to content
This repository has been archived by the owner on Apr 26, 2019. It is now read-only.

Commit

Permalink
fix: Fix throw error blocking parse
Browse files Browse the repository at this point in the history
  • Loading branch information
equinusocio committed Aug 16, 2017
1 parent a347790 commit d26c3b6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions demo/webcomponent/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<body>

<div class="clearfix mhl ptl">
<h1 class="mvm mtn fgc1">Grid Size: 0</h1>
<h1 class="mvm mtn fgc1">Grid Size: 24px</h1>
<div class="glyph fs1">
<div class="clearfix pbs">
<ikn-icon icon="linkedin"></ikn-icon><span class="name">linkedin</span>
<ikn-icon icon=""></ikn-icon><span class="name">linkedin</span>
</div>
</div>
<div class="glyph fs1">
Expand Down
2 changes: 1 addition & 1 deletion dist/ikonograph.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ikonograph.js

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions src/ikonograph.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const ICONS_SVG = {
};

const MIME_TYPE = 'image/svg+xml';
const ICON_DEFAULT = 'agenda';
const ICON_ATTR = 'icon';
const SIZE_ATTR = 'size';
const COLOR_ATTR = 'color';
Expand Down Expand Up @@ -36,10 +37,6 @@ class IkonographIcon extends HTMLElement {
const size = this.getAttribute(SIZE_ATTR);
const color = this.getAttribute(COLOR_ATTR);

if (!iconName) {
this._setIcon(iconName);
}

this._addStyleChild(size, color);
}

Expand Down Expand Up @@ -111,12 +108,12 @@ class IkonographIcon extends HTMLElement {
}

_addSVGChild(icon) {
const svgIconString = ICONS_SVG[icon];
if (!svgIconString) {
throw new Error('The specified icon does not exist');
if (!ICONS_SVG[icon]) {
console.warn('Ikonograph: The specified icon does not exist');
}

const svgElement = new DOMParser().parseFromString(ICONS_SVG[icon], MIME_TYPE);
const currentIcon = ICONS_SVG[icon] || ICONS_SVG[ICON_DEFAULT];
const svgElement = new DOMParser().parseFromString(currentIcon, MIME_TYPE);
svgElement.documentElement.removeAttribute('width');
svgElement.documentElement.removeAttribute('height');

Expand Down

0 comments on commit d26c3b6

Please sign in to comment.