Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): make sure selectors inside container queries are correctly scoped #48353

Conversation

dario-piotrowicz
Copy link
Contributor

@dario-piotrowicz dario-piotrowicz commented Dec 4, 2022

resolves #48264

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #48264

What is the new behavior?

Container queries get correctly shimmed by the emulated view encapsulation

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

  • This PR only allows the container queries to be correctly handled and does not provide any scoping for the container names, I am not sure if that is wanted/needed, I've put a comment on it in the issue regarding this

@pullapprove pullapprove bot requested a review from JoostK December 4, 2022 21:33
@dario-piotrowicz dario-piotrowicz force-pushed the fix-css-container-queries branch 2 times, most recently from 6c511cd to bf16ca8 Compare December 4, 2022 21:57
@dario-piotrowicz dario-piotrowicz changed the title fix(compiler): make sure container queries are correctly handled fix(compiler): make sure selectors inside container queries are correctly scoped Dec 4, 2022
Copy link
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

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

Thanks for this!

expect(result).toContain('.item[host-a] {');
});

it('should scope normal selectors inside a named container rules', () => {
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to see a test/assertion for the fact that the container name is not scoped, together with a comment similar to what you posted in the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a full match which ignores indentation via a noIndentation utility function, let me know if that works for you 🙂

Comment on lines 38 to 43
// Note that for the time being we are not scoping the container name itself,
// this is something that may or may not be done in the future depending
// on how the css specs evolve. Currently as of Chrome 107 it seems like shadowDom
// boundaries don't effect container queries (thus the scoping wouldn't be needed)
// And this aspect of container queries seems to be still under active discussion:
// https://github.com/w3c/csswg-drafts/issues/5984
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JoostK this got a bit verbose 😓 , I was wondering if I should just mention the fact but not explaining anything and just link to my comment in the issue instead?

something like:

Suggested change
// Note that for the time being we are not scoping the container name itself,
// this is something that may or may not be done in the future depending
// on how the css specs evolve. Currently as of Chrome 107 it seems like shadowDom
// boundaries don't effect container queries (thus the scoping wouldn't be needed)
// And this aspect of container queries seems to be still under active discussion:
// https://github.com/w3c/csswg-drafts/issues/5984
// Note that for the time being we are not scoping the container name itself,
// for more details see: https://github.com/angular/angular/issues/48264#issuecomment-1336524296

what do you prefer? 🙂

Copy link
Member

Choose a reason for hiding this comment

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

I like what you have in the PR now! 👍

Comment on lines 38 to 43
// Note that for the time being we are not scoping the container name itself,
// this is something that may or may not be done in the future depending
// on how the css specs evolve. Currently as of Chrome 107 it seems like shadowDom
// boundaries don't effect container queries (thus the scoping wouldn't be needed)
// And this aspect of container queries seems to be still under active discussion:
// https://github.com/w3c/csswg-drafts/issues/5984
Copy link
Member

Choose a reason for hiding this comment

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

I like what you have in the PR now! 👍

@JoostK JoostK added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release action: presubmit The PR is in need of a google3 presubmit area: compiler Issues related to `ngc`, Angular's template compiler labels Dec 5, 2022
@ngbot
Copy link

ngbot bot commented Dec 5, 2022

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "ci/circleci: setup" is failing
    pending status "google-internal-tests" is pending
    pending missing required status "ci/circleci: build"
    pending missing required status "ci/circleci: lint"
    pending missing required status "ci/angular: size"

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@ngbot ngbot bot modified the milestone: Backlog Dec 5, 2022
@JoostK
Copy link
Member

JoostK commented Dec 5, 2022

@dario-piotrowicz Could you please rebase the branch to make CI happy?

@AndrewKushnir AndrewKushnir added action: global presubmit The PR is in need of a google3 global presubmit and removed action: presubmit The PR is in need of a google3 presubmit labels Dec 5, 2022
@AndrewKushnir AndrewKushnir self-assigned this Dec 5, 2022
@dario-piotrowicz
Copy link
Contributor Author

@dario-piotrowicz Could you please rebase the branch to make CI happy?

done 🙂👍

…ctly scoped

improve the emulated shadowDom implementation so that it can correctly
scope selectors present inside the @container at-rule (recently added
to the css specs)

resolves angular#48264
@AndrewKushnir
Copy link
Contributor

AndrewKushnir commented Dec 6, 2022

Presubmit + Global Presubmit.

@AndrewKushnir AndrewKushnir added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Dec 6, 2022
@AndrewKushnir
Copy link
Contributor

Caretaker Note: Please ignore the google-internal-tests status. TGP is "green" after rerun.

@AndrewKushnir AndrewKushnir removed the action: global presubmit The PR is in need of a google3 global presubmit label Dec 6, 2022
@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit 4c02395.

AndrewKushnir pushed a commit that referenced this pull request Dec 6, 2022
…ctly scoped (#48353)

improve the emulated shadowDom implementation so that it can correctly
scope selectors present inside the @container at-rule (recently added
to the css specs)

resolves #48264

PR Close #48353
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Dec 23, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@angular/animations](https://github.com/angular/angular) | dependencies | patch | [`15.0.2` -> `15.0.4`](https://renovatebot.com/diffs/npm/@angular%2fanimations/15.0.2/15.0.4) |
| [@angular/common](https://github.com/angular/angular) | dependencies | patch | [`15.0.2` -> `15.0.4`](https://renovatebot.com/diffs/npm/@angular%2fcommon/15.0.2/15.0.4) |
| [@angular/compiler](https://github.com/angular/angular) | dependencies | patch | [`15.0.2` -> `15.0.4`](https://renovatebot.com/diffs/npm/@angular%2fcompiler/15.0.2/15.0.4) |
| [@angular/compiler-cli](https://github.com/angular/angular/tree/main/packages/compiler-cli) ([source](https://github.com/angular/angular)) | devDependencies | patch | [`15.0.2` -> `15.0.4`](https://renovatebot.com/diffs/npm/@angular%2fcompiler-cli/15.0.2/15.0.4) |
| [@angular/core](https://github.com/angular/angular) | dependencies | patch | [`15.0.2` -> `15.0.4`](https://renovatebot.com/diffs/npm/@angular%2fcore/15.0.2/15.0.4) |
| [@angular/forms](https://github.com/angular/angular) | dependencies | patch | [`15.0.2` -> `15.0.4`](https://renovatebot.com/diffs/npm/@angular%2fforms/15.0.2/15.0.4) |
| [@angular/platform-browser](https://github.com/angular/angular) | dependencies | patch | [`15.0.2` -> `15.0.4`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser/15.0.2/15.0.4) |
| [@angular/platform-browser-dynamic](https://github.com/angular/angular) | dependencies | patch | [`15.0.2` -> `15.0.4`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser-dynamic/15.0.2/15.0.4) |

---

### Release Notes

<details>
<summary>angular/angular</summary>

### [`v15.0.4`](https://github.com/angular/angular/blob/HEAD/CHANGELOG.md#&#8203;1504-2022-12-14)

[Compare Source](angular/angular@15.0.3...15.0.4)

##### animations

| Commit | Type | Description |
| -- | -- | -- |
| [6c1064c72f](angular/angular@6c1064c) | fix | fix incorrect handling of camel-case css properties ([#&#8203;48436](angular/angular#48436)) |

##### common

| Commit | Type | Description |
| -- | -- | -- |
| [f30d18a942](angular/angular@f30d18a) | fix | Fix TestBed.overrideProvider type to include multi ([#&#8203;48424](angular/angular#48424)) |

##### compiler-cli

| Commit | Type | Description |
| -- | -- | -- |
| [b55d2dab5d](angular/angular@b55d2da) | fix | evaluate const tuple types statically ([#&#8203;48091](angular/angular#48091)) |

#### Special Thanks

Alan Agius, Andrew Kushnir, Andrew Scott, Aristeidis Bampakos, Bob Watson, BrowserPerson, Jens, Jessica Janiuk, Joey Perrott, JoostK, Konstantin Kharitonov, Lukas Matta, Piotr Kowalski, Virginia Dooley, Yannick Baron, dario-piotrowicz, lsst25, piyush132000 and why520crazy

<!-- CHANGELOG SPLIT MARKER -->

### [`v15.0.3`](https://github.com/angular/angular/blob/HEAD/CHANGELOG.md#&#8203;1503-2022-12-07)

[Compare Source](angular/angular@15.0.2...15.0.3)

##### common

| Commit | Type | Description |
| -- | -- | -- |
| [50b1c2bf52](angular/angular@50b1c2b) | fix | Don't generate srcsets with very large sources ([#&#8203;47997](angular/angular#47997)) |
| [bf44dc234a](angular/angular@bf44dc2) | fix | Update `Location` to support base href containing `origin` ([#&#8203;48327](angular/angular#48327)) |

##### compiler

| Commit | Type | Description |
| -- | -- | -- |
| [9a5d84249a](angular/angular@9a5d842) | fix | make sure selectors inside container queries are correctly scoped ([#&#8203;48353](angular/angular#48353)) |

##### compiler-cli

| Commit | Type | Description |
| -- | -- | -- |
| [167bc0d163](angular/angular@167bc0d) | fix | Produce diagnostic rather than crash when using invalid hostDirective ([#&#8203;48314](angular/angular#48314)) |

##### core

| Commit | Type | Description |
| -- | -- | -- |
| [e4dcaa513e](angular/angular@e4dcaa5) | fix | unable to inject ChangeDetectorRef inside host directives ([#&#8203;48355](angular/angular#48355)) |

#### Special Thanks

Alan Agius, Alex Castle, Andrew Kushnir, Andrew Scott, Bob Watson, Derek Cormier, Joey Perrott, Konstantin Kharitonov, Kristiyan Kostadinov, Paul Gschwendtner, Pawel Kozlowski, dario-piotrowicz and piyush132000

<!-- CHANGELOG SPLIT MARKER -->

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC43MC4wIiwidXBkYXRlZEluVmVyIjoiMzQuNzAuNCJ9-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1684
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 6, 2023
trekladyone pushed a commit to trekladyone/angular that referenced this pull request Feb 1, 2023
…ctly scoped (angular#48353)

improve the emulated shadowDom implementation so that it can correctly
scope selectors present inside the @container at-rule (recently added
to the css specs)

resolves angular#48264

PR Close angular#48353
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSS Container query specificity issue
3 participants