Skip to content

Commit

Permalink
fix: only add novalidate attr if the rendered element is form
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Jul 16, 2020
1 parent 0ff1bad commit 3638cea
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions packages/core/src/Form.ts
Expand Up @@ -53,21 +53,29 @@ export const Form = defineComponent({

return () => {
const children = normalizeChildren(ctx, slotProps.value);
if (props.as) {
return h(
props.as,
{
// Disables native validation as vee-validate will handle it.
novalidate: true,
...ctx.attrs,
onSubmit,
onReset: handleFormReset,
},
children
);
if (!props.as) {
return children;
}

return children;
// Attributes to add on a native `form` tag
const formAttrs =
props.as === 'form'
? {
// Disables native validation as vee-validate will handle it.
novalidate: true,
}
: {};

return h(
props.as,
{
...formAttrs,
...ctx.attrs,
onSubmit,
onReset: handleFormReset,
},
children
);
};
},
});

0 comments on commit 3638cea

Please sign in to comment.