Uh oh!
There was an error while loading. Please reload this page.
feat: expose part=root for external CSS targeting - #341
Conversation
Wrap shadow root content in a <span part="text"> so consumers can style the inner element via ::part(text), enabling ::selection and other non-inheritable CSS properties to work across shadow boundaries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses Firefox-specific issues with text selection styling in shadow DOM by exposing a CSS part="text" attribute on the element's internal span. Firefox does not propagate custom ::selection styling into shadow DOM, so this change enables external CSS to target the element's text content using relative-time::part(text)::selection.
Changes:
- Modified the element to always render a root
<span>withpart="text"attribute in the shadow DOM - Updated tests to reflect that a span element is now always present
- Added test coverage to verify the
part="text"attribute exists
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/relative-time-element.ts | Refactored #updateRenderRootContent to always create a span element with part="text", rather than conditionally creating it only when aria-hidden is true |
| test/relative-time.js | Removed assertions checking for absence of span element, and added test suite for the new part attribute |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…den coexistence Document the shadow DOM `part="text"` attribute in a new Styling section with a CSS `::part()` usage example. Add test coverage verifying `part="text"` is preserved when `aria-hidden="true"` is also set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
part=text for external CSS targetingpart=root for external CSS targetingUh oh!
There was an error while loading. Please reload this page.
keithamus
commented
Feb 12, 2026
|
Thanks. I still think it's worth to pursue this change because as we know, Browser bugs can take years to be fixed. |
keithamus
commented
Feb 12, 2026
Sure, just closing the loop. |
siddharthkp
commented
Feb 17, 2026
@silverwind There's a failing test for you :) |
@siddharthkp it's a pre-existing flakyness on main branch, #342 will fix it. |
siddharthkp
commented
Feb 17, 2026
@silverwind Great! I've merged that in main and backmerged main here |
silverwind
commented
Feb 17, 2026
Thanks, branch should go green after latest main merge now. |
Uh oh!
There was an error while loading. Please reload this page.
silverwind
commented
Feb 17, 2026
@siddharthkp for next merge, I suggest you merge with "squash" because you got some of the intermediate commits now on main. |
Replace the `@github/relative-time-element` npm dependency with a vendored, simplified implementation. - Support 24h format rendering [PR 329](github/relative-time-element#329) - Enable `::selection` styling in Firefox [PR 341](github/relative-time-element#341) - Remove timezone from tooltips (It's always local timezone) - Clean up previous `title` workaround in tippy - Remove unused features - Use native `Intl.DurationFormat` with fallback for older browsers, remove dead polyfill - Add MIT license header to vendored file - Add unit tests - Add dedicated devtest page for all component variants --------- Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: Claude claude-opus-4-6 20250630 <noreply@anthropic.com>
Replace the `@github/relative-time-element` npm dependency with a vendored, simplified implementation. - Support 24h format rendering [PR 329](github/relative-time-element#329) - Enable `::selection` styling in Firefox [PR 341](github/relative-time-element#341) - Remove timezone from tooltips (It's always local timezone) - Clean up previous `title` workaround in tippy - Remove unused features - Use native `Intl.DurationFormat` with fallback for older browsers, remove dead polyfill - Add MIT license header to vendored file - Add unit tests - Add dedicated devtest page for all component variants --------- Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: Hanzo Dev <dev@hanzo.ai>
Resolves#259.
Firefox does not propagate custom
::selectionstyling into shadow DOM. To enable styling the selection color inside<relative-time>, expose arootpart which refers to the root<span>of the element which can then be targeted by CSS.The root
<span>now always renders, even in the absence ofaria-hidden, but that shouldn't cause any issues because Shadow DOM still encapsulates the content.Example before and after with this CSS: