Skip to content

Commit

Permalink
Update core to 1.2.32 and add support for titleId (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
isidrok authored Dec 22, 2020
1 parent 49e5b0a commit 14096ee
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
]
},
"peerDependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.20",
"@fortawesome/free-solid-svg-icons": "^5.15.1",
"@fortawesome/fontawesome-svg-core": "^1.2.32",
"react": ">=16.x"
},
"devDependencies": {
Expand All @@ -58,7 +57,8 @@
"@babel/preset-env": "^7.7.5",
"@babel/preset-react": "^7.7.4",
"@babel/preset-stage-3": "^7.0.0",
"@fortawesome/fontawesome-svg-core": "^1.2.25",
"@fortawesome/fontawesome-svg-core": "^1.2.32",
"@fortawesome/free-solid-svg-icons": "^5.15.1",
"@types/react": "^16.9.15",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
Expand Down
12 changes: 10 additions & 2 deletions src/components/FontAwesomeIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import PropTypes from 'prop-types'
import React from 'react'

export default function FontAwesomeIcon({ forwardedRef, ...props }) {
const { icon: iconArgs, mask: maskArgs, symbol, className, title } = props
const {
icon: iconArgs,
mask: maskArgs,
symbol,
className,
title,
titleId
} = props

const iconLookup = normalizeIconArgs(iconArgs)
const classes = objectWithKey('classes', [
Expand All @@ -28,7 +35,8 @@ export default function FontAwesomeIcon({ forwardedRef, ...props }) {
...transform,
...mask,
symbol,
title
title,
titleId
})

if (!renderedIcon) {
Expand Down
9 changes: 9 additions & 0 deletions src/components/__tests__/FontAwesomeIcon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,12 @@ describe('using ref', () => {
expect(forwardedRef).toBe(node)
})
})

describe('using titleId', () => {
test('setting titleId prop reflects in the aria-labelledby attribute', () => {
const titleId = 'foo'
const vm = mount({ icon: faCoffee, titleId: titleId, title: 'Coffee' })
const ariaLabelledby = vm.props['aria-labelledby']
expect(ariaLabelledby.includes(titleId)).toBeTruthy()
})
})

0 comments on commit 14096ee

Please sign in to comment.