Skip to content

Commit

Permalink
Add docs and remove unreachable line
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Nov 25, 2024
1 parent 8415577 commit 143b006
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/wp-includes/html-api/class-wp-css-selectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ private function __construct( string $ident ) {
$this->ident = $ident;
}

/**
* Parse an ID selector
*
* > <id-selector> = <hash-token>
*
* https://www.w3.org/TR/selectors/#grammar
*/
public static function parse( string $input, int &$offset ): ?self {
$ident = self::parse_hash_token( $input, $offset );
if ( null === $ident ) {
Expand All @@ -427,6 +434,13 @@ private function __construct( string $ident ) {
$this->ident = $ident;
}

/**
* Parse a class selector
*
* > <class-selector> = '.' <ident-token>
*
* https://www.w3.org/TR/selectors/#grammar
*/
public static function parse( string $input, int &$offset ): ?self {
if ( $offset + 1 >= strlen( $input ) || '.' !== $input[ $offset ] ) {
return null;
Expand All @@ -437,7 +451,6 @@ public static function parse( string $input, int &$offset ): ?self {

if ( null === $result ) {
return null;
$offset = $updated_offset;
}

$offset = $updated_offset;
Expand Down

0 comments on commit 143b006

Please sign in to comment.