Skip to content

Commit d723bae

Browse files
committed
Update docs to only allow subclass selectors in final complex selector position
1 parent f3ec729 commit d723bae

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/wp-includes/html-api/class-wp-css-selectors.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
* <selector-list> = <complex-selector-list>
2828
* <complex-selector-list> = <complex-selector>#
2929
* <compound-selector-list> = <compound-selector>#
30-
* <complex-selector> = <compound-selector> [ <combinator>? <compound-selector> ]*
30+
* <complex-selector> = [ <type-selector> <combinator>? ]* <compound-selector>
3131
* <compound-selector> = [ <type-selector>? <subclass-selector>* ]!
32-
* <combinator> = '>' | '+' | '~' | [ '|' '|' ]
32+
* <combinator> = '>' | [ '|' '|' ]
3333
* <type-selector> = <ident-token> | '*'
3434
* <subclass-selector> = <id-selector> | <class-selector> | <attribute-selector>
3535
* <id-selector> = <hash-token>
@@ -47,17 +47,23 @@
4747
* - ID selectors (e.g. `#unique-id`)
4848
* - Attribute selectors (e.g. `[attribute-name]` or `[attribute-name="value"]`)
4949
* - Comma-separated selector lists (e.g. `.selector-1, .selector-2`)
50-
* - The following combinators:
51-
* - descendant (e.g. `.parent .descendant`)
52-
* - child (`.parent > .child`)
50+
* - The following combinators. Only type (element) selectors are allowed in non-final position:
51+
* - descendant (e.g. `el .descendant`)
52+
* - child (`el > .child`)
5353
*
5454
* Unsupported selector syntax:
5555
* - Pseudo-element selectors (e.g. `::before`)
5656
* - Pseudo-class selectors (e.g. `:hover` or `:nth-child(2)`)
5757
* - Namespace prefixes (e.g. `svg|title` or `[xlink|href]`)
5858
* - The following combinators:
59-
* - Next sibling (`.sibling + .sibling`)
60-
* - Subsequent sibling (`.sibling ~ .sibling`)
59+
* - Next sibling (`el + el`)
60+
* - Subsequent sibling (`el ~ el`)
61+
*
62+
* Future ideas
63+
* - Namespace type selectors could be implemented with select namespaces in order to
64+
* select elements from a namespace, for example:
65+
* - `svg|*` to select all SVG elements
66+
* - `html|title` to select only HTML TITLE elements.
6167
*
6268
* @since TBD
6369
*

0 commit comments

Comments
 (0)