Skip to content

Bug: findIconDefinition requires prefix to be defined when is icon has diffrent prefix #20821

@cvanh

Description

@cvanh

Bug description

While working on setting up a Font Awesome subset for a React-based project, I wanted to use findIconDefinition(). I currently have our own icon names set up like this:

const ICON_MAP = {
  angleDown: faAngleDown
  ...
}

I want to phase out ICON_MAP so that we can use the regular Font Awesome names. For that, I chose to use a mapper that maps names such as angleDown to angle-down and passes this to findIconDefinition() in order to verify that the icon exists and that the types are correct.

The problem is that in the Font Awesome API docs, the use of findIconDefinition({ iconName: "<NAME>" }) is described. It works as expected, but when the icon is only available outside the fas prefix, it returns undefined. The expected behavior is that it also searches in other prefixes.

https://docs.fontawesome.com/apis/javascript/methods#basic-use

Reproducible test case

https://codepen.io/cvanh/pen/WbrpPRW

Screenshots

Image

Font Awesome version

v7

Serving

Kit

Implementation

Other (as specified in the bug description)

Browser and Operating System

  • Firefox 143 on macOS (Catalina)

Web bug report checklist

  • I have included a test case because my odds go way up that the team can fix this when I do
  • I have searched for existing issues and to the best of my knowledge this is not a duplicate

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triageThis bug needs to be confirmed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions