Skip to content
This repository was archived by the owner on Feb 23, 2022. It is now read-only.

Commit f952d9d

Browse files
committed
Allow :host() and :host-context() selectors.
Unlike ::slotted(), which only allows simple selectors inside the parens, :host and :host-context allow complex selectors to be placed inside the parens.
1 parent 94e2d57 commit f952d9d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

closure-stylesheets.iml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="false">
4+
<orderEntry type="sourceFolder" forTests="false" />
5+
</component>
6+
</module>

src/com/google/common/css/compiler/ast/GssParserCC.jj

+12
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ PARSER_END(GssParserCC)
707707
// Special handling needed because ':not' takes simple selectors as
708708
// an argument.
709709
| < NOTFUNCTION: "not" <LEFTROUND> >
710+
| < HOSTFUNCTION: "host" ("-context")? <LEFTROUND> >
710711
| < SLOTTEDFUNCTION: ":slotted" <LEFTROUND> >
711712
| < LANGFUNCTION: "lang" <LEFTROUND> >
712713

@@ -943,6 +944,17 @@ CssRefinerNode pseudo() :
943944
this.mergeLocations(beginLocation, endLocation), tokens); }
944945
)
945946
|
947+
( // :host( complex > selector ) or :host-context( complex > selector )
948+
t = <HOSTFUNCTION> ( <S> )* { beginLocation = this.getLocation();
949+
pseudo = t.image; tokens.add(t); }
950+
innerSelector = selector()
951+
( <S> )*
952+
t = <RIGHTROUND> { tokens.add(t);
953+
endLocation = this.getLocation();
954+
return nodeBuilder.buildPseudoClassNode(pseudo, innerSelector,
955+
this.mergeLocations(beginLocation, endLocation), tokens); }
956+
)
957+
|
946958
( // :lang( <IDENTIFIER> )
947959
t = <LANGFUNCTION> ( <S> )* { beginLocation = this.getLocation();
948960
pseudo = t.image; tokens.add(t); }

0 commit comments

Comments
 (0)