Skip to content

Commit 6e449d4

Browse files
Warn about incorrect icon name and handle gracefully (#1241)
* warn about incorrect icon name and handle gracefully * add changeset
1 parent 7830e75 commit 6e449d4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.changeset/tough-balloons-breathe.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'feather-icons': patch
3+
---
4+
5+
Feather no longer breaks when trying to replace an icon using an invalid name

src/replace.js

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ function replaceElement(element, attrs = {}) {
3131
const name = elementAttrs['data-feather'];
3232
delete elementAttrs['data-feather'];
3333

34+
if (icons[name] === undefined) {
35+
console.warn(`feather: '${name}' is not a valid icon`);
36+
return;
37+
}
38+
3439
const svgString = icons[name].toSvg({
3540
...attrs,
3641
...elementAttrs,

0 commit comments

Comments
 (0)