feat(apollo-wind): add registerCssPropertyRules for shadow DOM#830
feat(apollo-wind): add registerCssPropertyRules for shadow DOM#830david-rios-uipath wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
| it('does nothing when CSS has no @property rules', () => { | ||
| registerCssPropertyRules('.flex { display: flex; }'); | ||
|
|
||
| expect(document.querySelector(SELECTOR)).toBeNull(); | ||
| }); | ||
| }); |
📦 Dev Packages
|
- Fix ReDoS: remove capturing group and use [^}]* instead of [^}]+ - Add idempotency test to verify only one style element is injected
📊 Coverage + size by packagePer-package coverage and bundle size on this PR. New-line coverage = of the source lines this PR adds or changes, the % hit by tests.
"Coverage" is each package's own |
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)