Skip to content

Commit

Permalink
feat: added alert role to the error message
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Jun 28, 2020
1 parent b55829f commit 714abfe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/core/src/ErrorMessage.ts
Expand Up @@ -24,7 +24,10 @@ export const ErrorMessage = defineComponent({
});

const tag = props.as;
const id = genFieldErrorId(props.name);
const attrs = {
id: genFieldErrorId(props.name),
role: 'alert',
};

// If no tag was specified and there are children
// render the slot as is without wrapping it
Expand All @@ -35,13 +38,13 @@ export const ErrorMessage = defineComponent({
// If no children in slot
// render whatever specified and fallback to a <span> with the message in it's contents
if (!children.length) {
return h(tag || 'span', { id }, message.value);
return h(tag || 'span', attrs, message.value);
}

return h(
tag,
{
id,
...attrs,
...ctx.attrs,
},
children
Expand Down

0 comments on commit 714abfe

Please sign in to comment.