Skip to content

Commit

Permalink
fix pseudo element selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Aug 14, 2024
1 parent 82e199d commit 04948a6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Fixed parsing pseudo element selectors.

## v2.11.4

- Fixed parsing unclosed attribute selector (such as `a[href`).
Expand Down
7 changes: 4 additions & 3 deletions parser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ type GetLastTag<I> = I extends `${string}${Combinators}${infer Right}`
: GetLastTag<Right>
: I

type PseudoClassesFirstChar =
type PseudoFirstChar =
| ':'
| 'a'
| 'b'
| 'c'
Expand Down Expand Up @@ -108,9 +109,9 @@ type PostprocessEachUnchecked<I> =
? PostprocessEachUnchecked<`${Tag}&${Rest}`>
: I extends `${infer Tag}#${string}`
? PostprocessEachUnchecked<Tag>
: I extends `${infer Tag}:${PseudoClassesFirstChar}${string}&${infer Rest}`
: I extends `${infer Tag}:${PseudoFirstChar}${string}&${infer Rest}`
? PostprocessEachUnchecked<`${Tag}&${Rest}`>
: I extends `${infer Tag}:${PseudoClassesFirstChar}${string}`
: I extends `${infer Tag}:${PseudoFirstChar}${string}`
? PostprocessEachUnchecked<Tag>
: I extends `${string}|${infer Tag}` // namespace prefix
? PostprocessEachUnchecked<Tag>
Expand Down
1 change: 1 addition & 0 deletions parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ type _Tests = [
>,
Expect<Equal<ParseSelector<':func(arg)'>, Element>>,
Expect<Equal<ParseSelector<'::func(arg)'>, Element>>,
Expect<Equal<ParseSelector<'a::-p-text(Hello)'>, HTMLAnchorElement>>,
]

declare function delegate<
Expand Down

0 comments on commit 04948a6

Please sign in to comment.