Subscribe on changes!

Slot child boolean props not boolean if not passing boolean to component.

avatar
Feb 23rd 2022

Version

3.2.31

Reproduction link

sfc.vuejs.org/

Steps to reproduce

What is expected?

expected both to be booleans

What is actually happening?

components props.disabled is a string


Ran in to this bug when fixing this: https://github.com/cdmoro/bootstrap-vue-3/pull/240

avatar
Feb 23rd 2022

This is normal behavior. A vnode's props property contains the raw props. When a component instance is created for the vnode, the raw props are processed, and part of that if to cast boolean props correctly.

We can't reliably know during compilation that the vnode will represent a component (vs. a normal element), and thus fall back to the HTML behavior: custom boolean attributes are added to an element by using an empty string as the value:

el.setAttribute('my-attribute', '')

So we use an empty string as its value in vnode.props.

then, when we later at runtime know that the vnode represents a component and the prop is a boolean, we cast it before exposing it to the component as $props etc.

avatar
Feb 23rd 2022

Thai is expected and has been discussed already in other issues