From 97e6518535a4622a6c7a9a65133379ce854c670d Mon Sep 17 00:00:00 2001 From: robmadole Date: Sat, 2 Jul 2022 12:42:11 -0500 Subject: [PATCH] Alias feature detection includes icons package --- package.json | 3 ++- src/components/__fixtures__/helpers.js | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b14511bc..4479d653 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,8 @@ "react": ">=17.x", "react-dom": "^17.0.2", "react-test-renderer": "^17.0.2", - "rollup": "^2.64.0" + "rollup": "^2.64.0", + "semver": "^7.3.7" }, "dependencies": { "prop-types": "^15.8.1" diff --git a/src/components/__fixtures__/helpers.js b/src/components/__fixtures__/helpers.js index 7a96687d..f4cd8b7a 100644 --- a/src/components/__fixtures__/helpers.js +++ b/src/components/__fixtures__/helpers.js @@ -2,13 +2,24 @@ import React from 'react' import FontAwesomeIcon from '../FontAwesomeIcon' import renderer from 'react-test-renderer' import { parse } from '@fortawesome/fontawesome-svg-core' +import semver from 'semver' + +const SVG_ICONS_VERSION = semver.parse( + require('@fortawesome/free-solid-svg-icons/package.json').version +) export const REFERENCE_ICON_BY_STYLE = 0x00 export const ICON_ALIASES = 0x01 export const REFERENCE_ICON_USING_STRING = 0x02 export function coreHasFeature (feature) { - if (feature === REFERENCE_ICON_BY_STYLE || feature === ICON_ALIASES || feature === REFERENCE_ICON_USING_STRING) { + if (feature === ICON_ALIASES) { + // Aliases were not introduced until version 6 so we need to check the + // installed free-solid-svg-icons package as well. + return parse.icon && SVG_ICONS_VERSION.major >= 6 + } + + if (feature === REFERENCE_ICON_BY_STYLE || feature === REFERENCE_ICON_USING_STRING) { return parse.icon } }