Skip to content

Commit

Permalink
Warn about incorrect icon name and handle gracefully (#1241)
Browse files Browse the repository at this point in the history
* warn about incorrect icon name and handle gracefully

* add changeset
  • Loading branch information
braden-godley authored May 1, 2024
1 parent 7830e75 commit 6e449d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-balloons-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'feather-icons': patch
---

Feather no longer breaks when trying to replace an icon using an invalid name
5 changes: 5 additions & 0 deletions src/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ function replaceElement(element, attrs = {}) {
const name = elementAttrs['data-feather'];
delete elementAttrs['data-feather'];

if (icons[name] === undefined) {
console.warn(`feather: '${name}' is not a valid icon`);
return;
}

const svgString = icons[name].toSvg({
...attrs,
...elementAttrs,
Expand Down

0 comments on commit 6e449d4

Please sign in to comment.