Skip to content

Merged class attributes are not preserved when a component is created from a render function and the root node has a class binding #8187

Closed
@rodrigopedra

Description

@rodrigopedra

Version

2.5.16

Reproduction link

https://jsfiddle.net/jmabj70u/

updated: added child-compoent directly to compare expected vs actual results

https://jsfiddle.net/jmabj70u/1/

Steps to reproduce

  1. Create a component that render its content through a render function and render a child component with a static class attribute
  2. In the child component, add a class binding to the root element
  3. When the class binding is applied (for example, when a condition becomes true) the static classes passed from the parent component render function is lost

What is expected?

That the child component keeps both the static and dynamic classes

What is actually happening?

Only the dynamic classes added through the v-bind:class are kept in the root element


I looked through other issues reporting similar behaviors, the one more likely to be related is issue #1014 , but this one differs from that case since any of the components here are functional components.

updated: actual issue is vuejs/vue-loader#1014 (comment) see comment below

The example in the fiddle is a simplified version to showcase the problem. In my use-case, the parent component can render a different child component depending on a prop or state, the parent acts as a "proxy" or "polymorphic" component for several different children.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions