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

Commit

Permalink
Allow :host() and :host-context() selectors.
Browse files Browse the repository at this point in the history
Unlike ::slotted(), which only allows simple selectors
inside the parens, :host and :host-context allow
complex selectors to be placed inside the parens.
  • Loading branch information
JamesXNelson committed Mar 5, 2017
1 parent 94e2d57 commit f952d9d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions closure-stylesheets.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
12 changes: 12 additions & 0 deletions src/com/google/common/css/compiler/ast/GssParserCC.jj
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ PARSER_END(GssParserCC)
// Special handling needed because ':not' takes simple selectors as
// an argument.
| < NOTFUNCTION: "not" <LEFTROUND> >
| < HOSTFUNCTION: "host" ("-context")? <LEFTROUND> >
| < SLOTTEDFUNCTION: ":slotted" <LEFTROUND> >
| < LANGFUNCTION: "lang" <LEFTROUND> >

Expand Down Expand Up @@ -943,6 +944,17 @@ CssRefinerNode pseudo() :
this.mergeLocations(beginLocation, endLocation), tokens); }
)
|
( // :host( complex > selector ) or :host-context( complex > selector )
t = <HOSTFUNCTION> ( <S> )* { beginLocation = this.getLocation();
pseudo = t.image; tokens.add(t); }
innerSelector = selector()
( <S> )*
t = <RIGHTROUND> { tokens.add(t);
endLocation = this.getLocation();
return nodeBuilder.buildPseudoClassNode(pseudo, innerSelector,
this.mergeLocations(beginLocation, endLocation), tokens); }
)
|
( // :lang( <IDENTIFIER> )
t = <LANGFUNCTION> ( <S> )* { beginLocation = this.getLocation();
pseudo = t.image; tokens.add(t); }
Expand Down

0 comments on commit f952d9d

Please sign in to comment.