Skip to content

Commit c572391

Browse files
committed
Improve documentation
1 parent 2f47c32 commit c572391

2 files changed

Lines changed: 18 additions & 27 deletions

File tree

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

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class WP_CSS_Complex_Selector extends WP_CSS_Selector_Parser_Matcher {
4848
* The "self selector" is the last element in a complex selector, it corresponds to the
4949
* selected element.
5050
*
51-
* @example
51+
* Example:
5252
*
5353
* $self_selector
5454
* ┏━━━━┻━━━━┓
@@ -67,38 +67,28 @@ final class WP_CSS_Complex_Selector extends WP_CSS_Selector_Parser_Matcher {
6767
* the element at index 1 is the combinator string constant from this class,
6868
* e.g. `WP_CSS_Complex_Selector::COMBINATOR_CHILD`.
6969
*
70-
* In the example selector below, an element like `<el class="selected">` is selected iff:
70+
* In the example selector below, an element like `<strong class="selected">` matches iff:
7171
* - it is a child of an `H1` element
72-
* - *and* that `H1` element is a descendant of a `HEADING` element.
72+
* - that `H1` element is a descendant of a `SECTION` element.
7373
*
74-
* The `H1` and `HEADING` parts of this selector are the "context selectors." Note that this
75-
* terminology is used for purposes of this class but does not correspond to language in the
76-
* CSS or selector specifications.
77-
*
78-
* @example
74+
* The `section` and `h1` parts of this selector and their combinators are the
75+
* "context selectors." Note that this terminology does not correspond to language in the
76+
* specification texts.
7977
*
8078
* $context_selectors
81-
* ┏━━━━━━┻━━━━┓
82-
* .heading h1 > el.selected
83-
*
84-
* The example would have the following relative selectors:
79+
* ┏━━━━━┻━━━━┓
80+
* section h1 > strong.selected
8581
*
86-
* @example
82+
* The example would have the following context selectors:
8783
*
88-
* array (
89-
* array(
90-
* WP_CSS_Type_Selector( 'ident' => 'h1' ),
91-
* '>', // WP_CSS_Complex_Selector::COMBINATOR_CHILD
92-
* ),
93-
* array(
94-
* new WP_CSS_Type_Selector( 'header' ),
95-
* ' ', // WP_CSS_Complex_Selector::COMBINATOR_DESCENDANT
96-
* ),
84+
* // Pseudo-code
85+
* array(
86+
* array( WP_CSS_Type_Selector( 'type'=>'h1' ), '>' ),
87+
* array( WP_CSS_Type_Selector( 'type'=>'section' ), ' ' ),
9788
* )
9889
*
99-
* Note that the order of context selectors is reversed. This is to match the self selector
100-
* first and then match the context selectors beginning with the selector closest to the self
101-
* selector.
90+
* Context selectors are ordered from right to left in the selector text. The selectors closest
91+
* to the target appear at the start of the `context_selectors` array.
10292
*
10393
* @readonly
10494
* @var array{WP_CSS_Type_Selector, string}[]|null

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @link https://www.w3.org/TR/selectors/#grammar Refer to the grammar for more details.
4242
*
4343
* This class of selectors does not support "complex" selectors. That is any selector with a
44-
* combinator such as descendent (`.ancestor .descendant`) or child (`.parent > .child`).
44+
* combinator such as descendant (`.ancestor .descendant`) or child (`.parent > .child`).
4545
* See {@see WP_CSS_Complex_Selector_List} for support of some combinators.
4646
*
4747
* Note that this grammar has been adapted and does not support the full CSS selector grammar.
@@ -59,7 +59,8 @@
5959
* - Pseudo-element selectors (`::before`)
6060
* - Pseudo-class selectors (`:hover` or `:nth-child(2)`)
6161
* - Namespace prefixes (`svg|title` or `[xlink|href]`)
62-
* - Combinators are not supported (descendant, child, next sibling, subsequent sibling)
62+
* - Combinators are not supported by this class (descendant, child, next sibling,
63+
* subsequent sibling). See {@see WP_CSS_Complex_Selector_List} for combinator support.
6364
*
6465
* Future ideas:
6566
* - Namespace type selectors could be implemented with select namespaces in order to

0 commit comments

Comments
 (0)