Skip to content

Commit 2ae0099

Browse files
committed
Add nonfinal subclass selector test
1 parent 58ef563 commit 2ae0099

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/wp-includes/html-api/class-wp-css-complex-selector-list.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,13 @@ final protected static function parse_complex_selector( string $input, int &$off
134134
return null;
135135
}
136136

137-
// `div > .className` is valid, but `.className > div` is not.
137+
/*
138+
* Subclass selectors in non-final position is not supported:
139+
* - `div > .className` is valid
140+
* - `.className > div` is not
141+
*/
138142
if ( $has_preceding_subclass_selector ) {
139-
throw new Exception( 'Unsupported non-final subclass selector.' );
143+
return null;
140144
}
141145
$has_preceding_subclass_selector = null !== $selector->subclass_selectors;
142146

tests/phpunit/tests/html-api/wpCssComplexSelectorList.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ public function test_parse_invalid_complex_selector() {
5959
$this->assertNull( $result );
6060
}
6161

62+
/**
63+
* @ticket TBD
64+
*/
65+
public function test_parse_invalid_complex_selector_nonfinal_subclass() {
66+
$input = 'el.foo#bar[baz=quux] > final, rest';
67+
$offset = 0;
68+
$result = $this->test_class::test_parse_complex_selector( $input, $offset );
69+
$this->assertNull( $result );
70+
}
71+
6272
/**
6373
* @ticket TBD
6474
*/

0 commit comments

Comments
 (0)