Skip to content

Commit

Permalink
[CSS] Add :global() and :local() pseudo-classes (#3944)
Browse files Browse the repository at this point in the history
This commit adds `:global(selector)` and `:local(selector)` pseudo-class
support. The former is used by CSS Modules, Less and Astro framework.
The ladder is used by CSS Modules only, but is added for completeness.

It is no default CSS feature, but appears to be specific enough to not cause
any conflicts.

Adding it to core CSS would avoid the need to extend CSS for Astro, just
for this single reason.
  • Loading branch information
deathaxe authored Jul 12, 2024
1 parent 5dbbc4d commit a5ed29e
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions CSS/CSS.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ variables:

keyframe_selector_begin: (?=\b(?i:from|to){{break}}|\.?[\d,%])

pseudo_classes_with_selector_args: |-
(?xi: global | local | matches | is | where | not | has | host(?:-context)?)
pseudo_classes_with_anb_args: |-
(?xi:
# https://drafts.csswg.org/selectors-4/#table-pseudos
nth-last-col
| nth-col
# https://drafts.csswg.org/selectors-4/#typed-child-index
| nth-last-child
| nth-child
| nth-last-of-type
| nth-of-type
)
# Combinators
# https://drafts.csswg.org/selectors-4/#combinators
combinators: (?:>{1,3}|[~+]|\|{2})
Expand Down Expand Up @@ -1365,17 +1380,7 @@ contexts:
# Functional Pseudo Classes with `An+B` param
# An+B Notation: https://drafts.csswg.org/css-syntax/#anb
pseudo-class-function-with-anb-args:
- match: |-
(?xi:
# https://drafts.csswg.org/selectors-4/#table-pseudos
nth-last-col
| nth-col
# https://drafts.csswg.org/selectors-4/#typed-child-index
| nth-last-child
| nth-child
| nth-last-of-type
| nth-of-type
)(?=\()
- match: '{{pseudo_classes_with_anb_args}}(?=\()'
scope: meta.function-call.identifier.css entity.other.pseudo-class.css
set:
- pseudo-class-anb-arguments-list-body
Expand Down Expand Up @@ -1404,7 +1409,8 @@ contexts:

# Functional Pseudo Classes with selector list
pseudo-class-function-with-selector-args:
- match: (?i:matches|is|where|not|has|host(?:-context)?)(?=\()
# global(), local() - CSS Modules, Less, Astro
- match: '{{pseudo_classes_with_selector_args}}(?=\()'
scope: meta.function-call.identifier.css entity.other.pseudo-class.css
set:
- pseudo-class-selector-arguments-list-body
Expand Down

0 comments on commit a5ed29e

Please sign in to comment.