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
| style={ props.style } | ||
| > | ||
| <div class="v-badge__wrapper"> | ||
| <props.tag class="v-badge__wrapper"> |
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
|
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. |
|
The three examples with a badge inside a button or a tab, for the update @J-Sek asked for — I checked every
All eight wrap only a Worth noting for anyone tempted to change the default instead: it would not work. The same defect on @waterWang I have those three example updates ready in waterWang#1 — a single commit on top of this PR's branch, so merging it into |
630451f to
3d3f418
Compare
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