happy-dom icon indicating copy to clipboard operation
happy-dom copied to clipboard

disabled attribute rendered with 'false' instead of ''

Open Ken-vdE opened this issue 2 years ago • 0 comments

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).

Ken-vdE avatar Sep 06 '22 12:09 Ken-vdE