feat(apollo-wind): add registerCssPropertyRules for shadow DOM#830
Draft
david-rios-uipath wants to merge 1 commit into
Draft
feat(apollo-wind): add registerCssPropertyRules for shadow DOM#830david-rios-uipath wants to merge 1 commit into
david-rios-uipath wants to merge 1 commit into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Dependency License Review
License distribution
Excluded packages
|
There was a problem hiding this comment.
⚠️ Not ready to approve
The new helper claims idempotency but the unit tests don’t currently assert the idempotent behavior, leaving a key behavior unverified.
Pull request overview
Adds a new @uipath/apollo-wind utility to support Tailwind v4 inside Shadow DOM by extracting @property at-rules from a CSS string and registering them globally via a single marker <style> in document.head.
Changes:
- Introduces
registerCssPropertyRules(css)to extract Tailwind@propertyrules and inject them once at the document level. - Adds unit tests verifying extraction and filtering behavior.
- Exports the new utility from both the internal lib barrel and the public package entry point.
File summaries
| File | Description |
|---|---|
| packages/apollo-wind/src/lib/register-shadow-dom-properties.ts | Implements registerCssPropertyRules with regex-based extraction and idempotent DOM marker injection. |
| packages/apollo-wind/src/lib/register-shadow-dom-properties.test.ts | Adds tests for extraction, filtering, and (needs adjustment) idempotency coverage. |
| packages/apollo-wind/src/lib/index.ts | Re-exports the helper from the lib barrel. |
| packages/apollo-wind/src/index.ts | Re-exports the helper from the public API. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
Comment on lines
+44
to
+49
| it('does nothing when CSS has no @property rules', () => { | ||
| registerCssPropertyRules('.flex { display: flex; }'); | ||
|
|
||
| expect(document.querySelector(SELECTOR)).toBeNull(); | ||
| }); | ||
| }); |
| * ``` | ||
| */ | ||
|
|
||
| const PROPERTY_RE = /@property\s+(--[\w-]+)\s*\{[^}]+\}/g; |
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
Adds
registerCssPropertyRules(css)— a JS helper that extracts Tailwind v4@propertydeclarations from a CSS string and registers them at the document level. This is needed because browsers silently ignore@propertyrules inside shadow DOM<style>elements, breaking composable Tailwind utilities (border,shadow-*,ring-*,translate-*, etc.) inside shadow roots.See upstream discussion: tailwindlabs/tailwindcss#16772
Immediate consumer:
@uipath/traceview— migrating shared Tooltip from MUI to apollo-wind (Radix), which portals inside a shadow root.Demo
Changes
src/lib/register-shadow-dom-properties.ts— extracts@propertyrules via regex, injects a single<style data-tw-property-rules>intodocument.head. Idempotent (DOM-based check).src/lib/register-shadow-dom-properties.test.ts— 3 tests covering extraction, filtering, and no-op for CSS without@property.src/lib/index.tsandsrc/index.ts— exportregisterCssPropertyRulesfrom the root barrel.Usage
Follow-up
Testing
pnpm --filter @uipath/apollo-wind testpasses (912 tests)