Repository navigation
feat(label): convert to shadow DOM - #31657
brandyscarney wants to merge 5 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
The 3px comes from the markup change, not the shadow conversion. The h3 used to be the only child of ion-text, so iOS's h3:last-child { margin-bottom: 0 } applied. Shadow DOM can only style direct children, so it's now <h3><ion-text>…</ion-text></h3>. It's no longer a last child, so it keeps its 3px bottom margin. The scoped label renders this markup identically.
| <ion-text color="primary"> | ||
| <h3>H3 Title Text</h3> | ||
| </ion-text> | ||
| <h3><ion-text color="primary">H3 Title Text</ion-text></h3> |
There was a problem hiding this comment.
In shadow DOM, label's ::slotted() styles only reach its direct children, so a heading nested inside ion-text loses label's heading styles and gets the global typography instead. Moving ion-text inside the heading keeps the h3 a direct child, so it still gets label's styles. This is documented in BREAKING.md.
Issue number: internal
What is the current behavior?
ion-labelusesscopedencapsulation.What is the new behavior?
ion-labelto Shadow DOM.::slotted(), so heading and paragraph styles now apply toh1-h6andpelements that are direct children ofion-label.typography.cssandtypography.ionic.cssnow skip headings that are direct children ofion-label, using selectors likeh1:where(:not(ion-label > h1))for each heading level, so the label's heading styles apply to them. The:where()keeps the original specificity.::slotted(ion-label)styles take precedence over label's own styles in shadow DOM.:host-context, which only Chromium supports in shadow DOM.transform-originmixin instead of a render-timelabel-rtlclass.:host-contextrules for item classes that are no longer set (item-input,item-textarea,item-has-focus,item-has-value,item-has-placeholder), along with the focused and invalid color rules for stacked and floating labels.isRTL()checked when needed, instead of render-time classes.Does this introduce a breaking change?
BREAKING CHANGE:
ion-labelhas been converted to use Shadow DOM.h1-h6andpelements that are direct children ofion-label. Nested headings, such as<ion-label><ion-text><h3>, no longer get label styles and get the global typography instead. Moveion-textinside the heading or paragraph, or setcoloronion-label.h2 { font-size: 20px; }now take precedence over label's heading and paragraph styles. Scope them withh2:not(ion-label > h2)to keep the label styles.ion-labeldirectly, such as a class that setscolor, now take precedence over the default label styles.Other information
:not()and:where()selectors in the global typography need Firefox 84+ and 78+, and docs(breaking): add minimum browser versions for v10 #31605 raises the documented minimum to Firefox 89.