Inconstant `inheritAttrs` behavior in production and development
Version
3.0.2
Reproduction link
https://github.com/07akioni/vue-inherit-attrs-bug
Steps to reproduce
npm run dev
npm run build
, then serve dist
What is expected?
I'm not sure which is expected by vue. I expect the dev behavior
What is actually happening?
behavior is inconstant
I'd rather say that the dev behaviour is wrong.
- slots return a fragment,
- and as the component has the slot as it's root node, it returns a fragment
- and attribute inheritance is not supported on fragments.
However in dev, components can "accidentally return a fragment if they have one root node but also one or more root comments, which are preserved in dev, but not in prod.
So in dev, we "pull out" this root node from the fragment - and in this instance, that should not happen as no comments are involved.
Relevant code:
That function should not be called on a fragment resulting from a slot, or maybe check for actual Comment nodes to be present - not sure yet about the best approach.
Why attribute inheritance is not supported on fragments,is it limited by the difficulty of implementation? @LinusBorg
Because its unclear on which element to inherit.
- Only the first one?
- Or all?
The latter would create invalid HTML for an id
attribute, for example, but it could be useful for a class
.