Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(image): allow empty string for alt and title property #250

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export interface ReactAvatarProps {
/**
* The alt attribute used on the avatar img tag. If not set we will fallback to either name or value
*/
alt?: string;
alt?: string | boolean;
/**
* The title attribute used on the avatar img tag. If not set we will fallback to either name or value
*/
title?: string;
title?: string | boolean;
/**
* Used in combination with `name` and `value`. Give the background a fixed color with a hex like for example #FF0000
*/
Expand Down
5 changes: 4 additions & 1 deletion src/components/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export default
class AvatarImage extends React.PureComponent {

static propTypes = {
alt: PropTypes.string,
alt: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool
]),
title: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function setGroupedTimeout(fn, ttl) {
export
function getNullableText(...args) {
for (const arg of args) {
if (arg)
if (arg || arg === '')
return arg;

if (arg === false || arg === null)
Expand Down