-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prefixed pseudo selectors to unions
- Loading branch information
Showing
6 changed files
with
133 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as selectors from 'mdn-data/css/selectors.json'; | ||
import { alternativeSelectors } from './compat'; | ||
import { addType, ResolvedType, Type } from './typer'; | ||
|
||
const REGEX_SIMPLE_PSEUDO_SELECTOR = /(?!:?:[\w-]+\()(:?:[\w-]+)/g; | ||
const REGEX_ADVANCED_PSEUDO_SELECTOR = /(:?:[\w-]+)\(/g; | ||
|
||
export let simplePseudos: ResolvedType[] = []; | ||
export let advancedPseudos: ResolvedType[] = []; | ||
|
||
for (const selector in selectors) { | ||
let match: RegExpMatchArray | null = null; | ||
while ((match = REGEX_SIMPLE_PSEUDO_SELECTOR.exec(selectors[selector].syntax))) { | ||
simplePseudos = addType(simplePseudos, { type: Type.StringLiteral, literal: match[1] }); | ||
|
||
for (const alternative of alternativeSelectors(match[1])) { | ||
simplePseudos = addType(simplePseudos, { type: Type.StringLiteral, literal: alternative }); | ||
} | ||
} | ||
while ((match = REGEX_ADVANCED_PSEUDO_SELECTOR.exec(selectors[selector].syntax))) { | ||
advancedPseudos = addType(advancedPseudos, { type: Type.StringLiteral, literal: match[1] }); | ||
|
||
for (const alternative of alternativeSelectors(match[1])) { | ||
advancedPseudos = addType(advancedPseudos, { type: Type.StringLiteral, literal: alternative }); | ||
} | ||
} | ||
} |