New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CssSelector] add support for :is() and :where() #48803
base: 6.3
Are you sure you want to change the base?
Conversation
f2d4128
to
d1d438d
Compare
d56aef3
to
b71d1b6
Compare
You should rebase instead of merging 6.3 |
8f4129d
to
8872ef6
Compare
8872ef6
to
26eefb3
Compare
My bad, I used the GitHub UI to resolve conflicts |
@@ -46,9 +46,10 @@ public function getElement(): string | |||
/** | |||
* @return $this | |||
*/ | |||
public function addCondition(string $condition): static | |||
public function addCondition(string $condition/* , string $conjunction = 'and' */): static |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is internal as well, can't we add the new argument directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal classes are not covered by the BC policy, so we can add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Update done.
|
||
public function getSpecificity(): Specificity | ||
{ | ||
return new Specificity(0, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this class represent <selector>:where(<subSelectorList>)
or just :where(<subSelectorList>)
? The specificity is 0 only in the second case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class includes the selector. I made changes to add selector specificity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, this looks broken in the Python library as well.
) { | ||
} | ||
|
||
public function getSpecificity(): Specificity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this class represent <selector>:is(<subSelectorList>)
or only :is(<subSelectorList>)
? In the first case, the specificity of <selector>
needs to be taken into account
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class includes the selector. I made changes to add selector specificity.
@@ -34,7 +34,7 @@ public function __construct( | |||
|
|||
public function getSpecificity(): Specificity | |||
{ | |||
return new Specificity(0, 0, 0); | |||
return $this->selector->getSpecificity()->plus(new Specificity(0, 0, 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be simplified as return $this->selector->getSpecificity();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed !
|
||
public function getSpecificity(): Specificity | ||
{ | ||
return new Specificity(0, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, this looks broken in the Python library as well.
@@ -46,9 +46,9 @@ public function getElement(): string | |||
/** | |||
* @return $this | |||
*/ | |||
public function addCondition(string $condition): static | |||
public function addCondition(string $condition, string $conjunction = 'and'): static |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the argument should be named operator
, not conjuction
. When using or
, you create a disjunction.
{ | ||
$arguments = []; | ||
while (true) { | ||
[$result, $pseudoElement] = $this->parseSimpleSelector($stream, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming in this parser is confusing. parseSimpleSelector
is not parsing a simple selector but a compound selector. However, this is still wrong for the parsing of is
and where
. They take a selector list, i.e. a list of complex selectors, not of compound selectors (see https://www.w3.org/TR/selectors-4/#structure for the terminology)
This PR adds support for :is() and :where() pseudo-classes.