Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconstant inheritAttrs behavior in production and development #2549

Closed
07akioni opened this issue Nov 3, 2020 · 4 comments
Closed

Inconstant inheritAttrs behavior in production and development #2549

07akioni opened this issue Nov 3, 2020 · 4 comments
Labels
🐞 bug Something isn't working

Comments

@07akioni
Copy link
Contributor

07akioni commented Nov 3, 2020

Version

3.0.2

Reproduction link

https://github.com/07akioni/vue-inherit-attrs-bug

Steps to reproduce

  1. npm run dev
    image

  2. npm run build, then serve dist
    image

What is expected?

I'm not sure which is expected by vue.
I expect the dev behavior

What is actually happening?

behavior is inconstant

@LinusBorg
Copy link
Member

LinusBorg commented Nov 3, 2020

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:

https://github.com/vuejs/vue-next/blob/f28ca556925147bb109d5ba77c5dafaf17d57322/packages/runtime-core/src/componentRenderUtils.ts#L216-L247

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.

@LinusBorg LinusBorg added the 🐞 bug Something isn't working label Nov 3, 2020
@luwuer
Copy link
Contributor

luwuer commented Nov 9, 2020

Why attribute inheritance is not supported on fragments,is it limited by the difficulty of implementation? @LinusBorg

@LinusBorg
Copy link
Member

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.

@luwuer
Copy link
Contributor

luwuer commented Nov 9, 2020

I got it, thx.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants