-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DomCrawler] Leverage PHP 8.4 DOM addition of native query selectors #57605
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
Comments
Does that mean, we could deprecate the whole CssSelector component? |
That's what I thought at first, but CssSelector is actually a translator from XPath to CSS syntax, which could be useful for many devs. I think it still has its place in the components ecosystem, but it definitely can be removed from DomCrawler dependencies at some point. |
Okay, but if the DOM extension can select by CSS selectors directly, why would I still need such a translator? I mean, if we deprecated the component, it would still be around for as long as we maintain Symfony 7.4 (November 2028). |
I suggest we first work on leveraging the new native feature in DomCrawler before making a decision on the future of the CssSelector component (we have until the release cycle of Symfony 7.4 to decide whether we should deprecate the CssSelector component to remove it in 8.0). and btw, this will also depend on what PHP requirement we decide to use in Symfony 8.0, which is not decided yet. |
Thank you for this suggestion. |
Still relevant once #54383 progresses |
Uh oh!
There was an error while loading. Please reload this page.
Description
Support for native HTML5 parser is being added to DomCrawler.
Lately, a lot of great additions are being added to the new DOM extension, especially query selectors : https://wiki.php.net/rfc/dom_additions_84 (it's the first section of the RFC).
DomCrawler could definitely benefit from this. At this time, the component is using CssSelector (the dependency is in the
require-dev
section currently). It would be nice to leverage this new native feature also when available !I think it is not a good idea to bring support right now in the WIP PR, it is already kind of huge and complex, and we should do this step by step. For the record, the patch was merged in the engine upstream already: php/php-src#13819.
I'm creating this issue so we don't forget about it 😄 Indeed related to #53666
Example
The Crawler API wouldn't change, but internals of
Crawler::matches
,Crawler::closest()
and alike would leverage the new native API.The text was updated successfully, but these errors were encountered: