Skip to content

fix(runtime-vapor): preserve omitted vs empty class attribute in setClass - #16432

Open
seragAhmed wants to merge 1 commit into
vuejs:minorfrom
seragAhmed:fix/16422-vapor-svg-v-bind-class
Open

seragAhmed wants to merge 1 commit into
vuejs:minorfrom
seragAhmed:fix/16422-vapor-svg-v-bind-class

Conversation

@seragAhmed

Copy link
Copy Markdown

Fixes #16422.

In Vapor, setClass() and setClassIncremental() previously normalized null/undefined to "", which conflated an omitted class prop with an explicit empty class: "" value:

  • Setting { class: "" } on a root element with no authored class attribute skipped writing class="" (and on non-root elements Element.prototype.$cls defaulted to "", skipping the first empty write).
  • Removing class from v-bind on a root element removed tokens via classList.remove() and left a stale empty class="" attribute instead of calling removeAttribute('class').

This preserves null vs "" across $cls, $clsi, $clsi$, and RootMeta.cls:

  • Explicitly empty "" ensures the class="" attribute is present on both root and non-root elements.
  • null/undefined removes the class attribute when neither the other root layer nor the template authors a class attribute and classList is empty.
  • Element.prototype.$cls is initialized to undefined so an initial empty string write is not skipped.

Verification

  • Added VDOM/Vapor parity tests in packages/runtime-vapor/__tests__/dom/svg.spec.ts covering root SVG v-bind, non-root SVG v-bind, authored empty class="", and fallthrough class interaction.
  • Updated packages/runtime-vapor/__tests__/hydration/interopSlots.spec.ts where removing fallthrough class from an element without a static class now removes the empty class attribute to match VDOM.
  • Ran pnpm check, pnpm lint, and pnpm vitest run on packages/runtime-vapor.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ddd70914-ac71-4f64-939c-deda2097f0dd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants