happy-dom
happy-dom copied to clipboard
disabled attribute rendered with 'false' instead of ''
The original issue can be found here: https://github.com/vuejs/test-utils/pull/1759
The disabled attribute gets set to 'false', which is incorrect. The spec does not allow for false values, as per https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes.
The issue arises here (using Vue Test Utils):
<template>
<component :is="type" :disabled="index > 1" @click="$emit('something')" data-testid="button"/>
</template>
And running a test like this:
const wrapper = mount(Component, { props: { type: 'button' } })
const button = wrapper.find('[data-testid="button"]')
await button.trigger('click');
expect(wrapper.emitted()).toHaveProperty('something')
Does not work because the this.attributes().disabled (in Test Utils baseWrapper) returns 'false' instead of undefined...
That means the dom was rendered incorrectly (... disabled="false"
instead of not having disabled attribute).