Skip to content

Commit

Permalink
Add nonfinal subclass selector test
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Dec 4, 2024
1 parent a27b3b2 commit e5e4c7e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,13 @@ final protected static function parse_complex_selector( string $input, int &$off
return null;
}

// `div > .className` is valid, but `.className > div` is not.
/*
* Subclass selectors in non-final position is not supported:
* - `div > .className` is valid
* - `.className > div` is not
*/
if ( $has_preceding_subclass_selector ) {
throw new Exception( 'Unsupported non-final subclass selector.' );
return null;
}
$has_preceding_subclass_selector = null !== $selector->subclass_selectors;

Expand Down
10 changes: 10 additions & 0 deletions tests/phpunit/tests/html-api/wpCssComplexSelectorList.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ public function test_parse_invalid_complex_selector() {
$this->assertNull( $result );
}

/**
* @ticket TBD
*/
public function test_parse_invalid_complex_selector_nonfinal_subclass() {
$input = 'el.foo#bar[baz=quux] > final, rest';
$offset = 0;
$result = $this->test_class::test_parse_complex_selector( $input, $offset );
$this->assertNull( $result );
}

/**
* @ticket TBD
*/
Expand Down

0 comments on commit e5e4c7e

Please sign in to comment.