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

CSS encapsulation breaks classes with escaped : colon in name #31844

Closed
jinsupark opened this issue Jul 25, 2019 · 1 comment
Closed

CSS encapsulation breaks classes with escaped : colon in name #31844

jinsupark opened this issue Jul 25, 2019 · 1 comment
Assignees
Labels
area: core Issues related to the framework runtime core: CSS encapsulation freq1: low P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: has PR type: bug/fix
Milestone

Comments

@jinsupark
Copy link

jinsupark commented Jul 25, 2019

🐞 bug report

Affected Package

Not sure sorry..

Is this a regression?

Not sure sorry..

Description

When inside custom.component.scss, css encapsulation with auto-assigned angular data-attribute does not works as intended when the escaped character includes a colon.

REPRODUCTION

// this works even with css encapsulation
.custom\/red {
    padding: 20px;
    background: red;
}
// this will produce the class .custom/red[_ngcontent-sno-c1]

// however this doesn't work
.custom\:blue {
    padding: 20px;
    background: blue;
}
// this produces the class .custom[_ngcontent-sno-c1]:blue

WHAT IS EXPECTED

.custom\/red[_ngcontent-sno-c1] {
    padding: 20px;
    background: red;
}

.custom\:blue[_ngcontent-sno-c1] {
    padding: 20px;
    background: blue;
}

WHAT IS RETURNED

.custom\/red[_ngcontent-sno-c1] {
    padding: 20px;
    background: red;
}

.custom\[_ngcontent-sno-c1]:blue {
    padding: 20px;
    background: blue;
}

As you can see the data-attribute that is assigned shifts in between the backslash and the colon which makes this class unusable.

WORKAROUND

Workaround to solve this is to turn off css encapsulation.

🌍 Your Environment

Angular 7

@AndrewKushnir AndrewKushnir added the area: core Issues related to the framework runtime label Jul 25, 2019
@ngbot ngbot bot added this to the needsTriage milestone Jul 25, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Aug 20, 2019
@jelbourn jelbourn added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed severity3: broken labels Oct 1, 2020
crisbeto added a commit to crisbeto/angular that referenced this issue Dec 25, 2020
CSS supports escaping in selectors, e.g. writing `.foo:bar` will match an element with the
`foo` class and `bar` pseudo-class, but `.foo\:bar` will match the `foo:bar` class. Our
shimmed shadow DOM encapsulation always assumes that `:` means a pseudo selector
which breaks a selector like `.foo\:bar`.

These changes add some extra logic so that escaped characters in selectors are preserved.

Fixes angular#31844.
@crisbeto crisbeto self-assigned this Dec 25, 2020
crisbeto added a commit to crisbeto/angular that referenced this issue Jan 6, 2021
CSS supports escaping in selectors, e.g. writing `.foo:bar` will match an element with the
`foo` class and `bar` pseudo-class, but `.foo\:bar` will match the `foo:bar` class. Our
shimmed shadow DOM encapsulation always assumes that `:` means a pseudo selector
which breaks a selector like `.foo\:bar`.

These changes add some extra logic so that escaped characters in selectors are preserved.

Fixes angular#31844.
josephperrott pushed a commit that referenced this issue Jan 6, 2021
…ces (#40264)

CSS supports escaping in selectors, e.g. writing `.foo:bar` will match an element with the
`foo` class and `bar` pseudo-class, but `.foo\:bar` will match the `foo:bar` class. Our
shimmed shadow DOM encapsulation always assumes that `:` means a pseudo selector
which breaks a selector like `.foo\:bar`.

These changes add some extra logic so that escaped characters in selectors are preserved.

Fixes #31844.

PR Close #40264
@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 Feb 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime core: CSS encapsulation freq1: low P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: has PR type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants