fix(VBadge): make wrapper element use tag prop for valid HTML nesting (Fixes #23093) - #23095
Open
waterWang wants to merge 1 commit into
Open
fix(VBadge): make wrapper element use tag prop for valid HTML nesting (Fixes #23093)#23095waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
The v-badge__wrapper element was hardcoded as a div, which produces invalid HTML when VBadge is nested inside VBtn (whose content wrapper is a span - phrasing content). The W3C validator reports: Element div not allowed as child of element span in this context. Fix: use the tag prop for both the root element and the wrapper, so that when tag=span (or any phrasing-valid tag) is passed, both elements produce valid phrasing content. Fixes vuetifyjs#23093
J-Sek
reviewed
Aug 11, 2026
| style={ props.style } | ||
| > | ||
| <div class="v-badge__wrapper"> | ||
| <props.tag class="v-badge__wrapper"> |
Contributor
There was a problem hiding this comment.
This would be fine if we are convinced tag on <v-badge> is never used in real life. Otherwise it is too risky
Contributor
|
We have badges within buttons and tabs across handful of examples. Assuming we don't bail on the risk of regression, those should be updated in the same PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
VBadgeis used insideVBtn(as shown in the VBadge documentation), the rendered HTML is invalid becauseVBadgehardcodes<div class="v-badge__wrapper">insideVBtn's<span class="v-btn__content">wrapper. The W3C validator reports:Fix
Make the
v-badge__wrapperelement use thetagprop instead of being hardcoded as a<div>. Whentag="span"(or any phrasing-valid tag) is passed, both the root element and the wrapper element produce valid phrasing content.Before (invalid HTML)
After (valid HTML with tag="span")
Backward compatibility
Default
tag="div"produces identical output to before:div > div > ...Fixes #23093