Skip to content

Don't warn about Angular's ::ng-deep and :host-context() when optimizing CSS - #20434

Merged
RobinMalfait merged 3 commits into
tailwindlabs:mainfrom
weilinzung:fix/ignore-angular-pseudo-selector-warnings
Aug 31, 2026
Merged

Don't warn about Angular's ::ng-deep and :host-context() when optimizing CSS#20434
RobinMalfait merged 3 commits into
tailwindlabs:mainfrom
weilinzung:fix/ignore-angular-pseudo-selector-warnings

Conversation

@weilinzung

Copy link
Copy Markdown
Contributor

Fixes #20433.

The warning filter in optimize.ts already ignores :deep(), :slotted() and :global(). Angular's two deep selectors are the same kind of thing — non-standard pseudo-selectors that the framework's compiler resolves before the CSS reaches a browser — but they aren't covered, so every Angular component stylesheet using them prints a warning block per occurrence.

Found 2 warnings while optimizing generated CSS:

Issue #1:
│ :host ::ng-deep .some-child, :host
┆        ^-- 'ng-deep' is not recognized as a valid pseudo-element. Did you mean ':ng-deep' (pseudo-class) or is this a typo?

Angular strips both during view-encapsulation shimming — ::ng-deep via _shadowDeepSelectors = /(?:>>>)|(?:\/deep\/)|(?:::ng-deep)/g, and :host-context() in the same pass — so neither ever reaches a browser.

Worth noting that /deep/ and >>>, Angular's two other spellings of the deep selector, already pass silently because nonStandard.deepSelectorCombinator is enabled. ::ng-deep is the only one that warns, and it's the spelling the Angular docs use — so in practice every Angular codebase hits this. On the workspace where I ran into it (7 Angular apps), a production build printed 425 ng-deep warnings and 2 host-context ones.

Test plan

There's no automated coverage here because the warning path is behind process.env.NODE_ENV !== 'test', so a spy sees nothing under Vitest regardless of the filter — the same reason #20277 shipped without one. Instead I ran the file before and after the change against Lightning CSS 1.33.0 directly, counting emitted warning blocks:

Input Before After
:host ::ng-deep .a, :host ::ng-deep .b { … } 1 0
:host-context(.dark) .a { … } 1 0
:deep(.a) { … } 0 0
.a::totally-not-real { … } — genuine typo 1 1

Generated CSS is byte-identical before and after; only the warning is suppressed. Genuine unknown pseudo-selectors still warn, so the typo hint the message exists for is preserved.

Happy to restructure this if you'd prefer the predicate extracted so it can be unit-tested, or to split ng-deep and host-context into their own block rather than extending the existing regex.

A minimal reproduction of the original issue is at https://gist.github.com/weilinzung/ace42ceb95c2f47b6747cc1f34f162bd.

@weilinzung
weilinzung requested a review from a team as a code owner August 26, 2026 16:07
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 64dd569f-7c3e-482e-b318-66d65dce2dd7

📥 Commits

Reviewing files that changed from the base of the PR and between 1283281 and 635abb6.

📒 Files selected for processing (1)
  • packages/@tailwindcss-node/src/optimize.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

CSS optimization no longer reports unknown pseudo-class and pseudo-element warnings for Vue selectors (:deep, :slotted, :global) and Angular selectors (::ng-deep, :host-context). The warning-filter documentation and Unreleased changelog entry now describe the Angular selector handling.

Merge Risk: ⚪ Minimal · up to 635ab

This narrowly suppresses warnings for Angular selectors that are removed before reaching browsers while preserving warnings for genuine unknown selectors; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: suppressing CSS optimization warnings for Angular's ::ng-deep and :host-context() selectors.
Description check ✅ Passed The description explains the Angular warning issue, the filter change, expected behavior, and test results. It is directly related to the changeset.
Linked Issues check ✅ Passed The implementation satisfies issue #20433 by filtering warnings for Angular's ::ng-deep and :host-context() selectors while preserving generated CSS and warnings for genuine unknown pseudo-selecto…
Out of Scope Changes check ✅ Passed The changes are limited to the optimizer warning filter, explanatory comments, and a related changelog entry. No unrelated code changes are present.
Full details: Linked Issues check

Explanation

The implementation satisfies issue #20433 by filtering warnings for Angular's ::ng-deep and :host-context() selectors while preserving generated CSS and warnings for genuine unknown pseudo-selectors.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (2): Last reviewed commit: "Update packages/@tailwindcss-node/src/op..." | Re-trigger Greptile

Comment thread packages/@tailwindcss-node/src/optimize.ts Outdated
weilinzung and others added 3 commits August 31, 2026 12:08
…imizing CSS

The filter already ignores `:deep()`, `:slotted()` and `:global()`. Angular's
two deep selectors are the same kind of thing — non-standard pseudo-selectors
resolved by the framework's compiler before the CSS reaches a browser — but
they were not covered, so every Angular component stylesheet using them printed
a warning block per occurrence.
@RobinMalfait
RobinMalfait force-pushed the fix/ignore-angular-pseudo-selector-warnings branch from 64bf7b4 to 635abb6 Compare August 31, 2026 10:08

@RobinMalfait RobinMalfait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@RobinMalfait
RobinMalfait enabled auto-merge (squash) August 31, 2026 10:11
@RobinMalfait
RobinMalfait merged commit f723e83 into tailwindlabs:main Aug 31, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimizer warns on Angular's ::ng-deep — the :deep/:slotted/:global filter doesn't cover it

2 participants