Skip to content

Empty class attribute applied by default to rendered RouterLink element #2804

@r-frederick

Description

@r-frederick

Version

3.0.3

Reproduction link

https://codesandbox.io/s/vue-template-2omcj?fontsize=14&module=%2Fsrc%2FApp.vue

Steps to reproduce

See reproduction in sandbox for reference (see App.vue for relevant parts).

  1. Define default styles that only apply when another class is not applicable.
  2. Insert a with no classes defined.
  3. Observe that the default styles using not([class]) do not take effect.

What is expected?

When the link is inactive or does not match the current route no classes should be applied and the attribute should not exist on the rendered element.

What is actually happening?

No classes are being applied to the rendered element, but the class attribute still exists as it's included in the createElement call (class properties on data).


I'd prefer to not discuss whether or not the "not" selector should be used this way. It's a fairly reasonable expectation to have no class attribute on the element when classes aren't being applied.

If desired, I could submit a PR with a bugfix for this issue. From my limited experimentation, it seems fairly trivial to implement a fix.

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