Skip to content

Commit

Permalink
fix(Avatar): prevent boolean src
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Mar 1, 2022
1 parent 4d0709a commit da3ed26
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/runtime/components/elements/Avatar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<span :class="wrapperClass">
<img v-if="src" :class="avatarClass" :src="src" :alt="alt">
<img v-if="url" :class="avatarClass" :src="url" :alt="alt">
<span v-else-if="text || placeholder" :class="placeholderClass">{{ text || placeholder }}</span>

<span v-if="chip" :class="chipClass" />
Expand Down Expand Up @@ -94,6 +94,13 @@ const chipClass = computed(() => {
)
})
const url = computed(() => {
if (typeof props.src === 'boolean') {
return null
}
return props.src
})
const placeholder = computed(() => {
return (props.alt || '').split(' ').map(word => word.charAt(0)).join('').substr(0, 2)
})
Expand Down

1 comment on commit da3ed26

@vercel
Copy link

@vercel vercel bot commented on da3ed26 Mar 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.