diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 55b5d8bc23f..7f2b28ad582 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -187,10 +187,14 @@ Get the same level nodes after or before the current selection:: $crawler->filter('body > p')->nextAll(); $crawler->filter('body > p')->previousAll(); -Get all the child or parent nodes:: +Get all the child or ancestor nodes:: $crawler->filter('body')->children(); - $crawler->filter('body > p')->parents(); + $crawler->filter('body > p')->ancestors(); + +.. versionadded:: 5.3 + + The ``ancestors()`` method was introduced in Symfony 5.3. Get all the direct child nodes matching a CSS selector:: diff --git a/testing.rst b/testing.rst index 2c0535eddfa..261786ff108 100644 --- a/testing.rst +++ b/testing.rst @@ -713,7 +713,7 @@ selects the last one on the page, and then selects its immediate parent element: $newCrawler = $crawler->filter('input[type=submit]') ->last() - ->parents() + ->ancestors() ->first() ; @@ -735,8 +735,8 @@ Many other methods are also available: All following siblings. ``previousAll()`` All preceding siblings. -``parents()`` - Returns the parent nodes. +``ancestors()`` + Returns the ancestor nodes. ``children()`` Returns children nodes. ``reduce($lambda)`` @@ -766,7 +766,7 @@ Extracting Information The Crawler can extract information from the nodes:: use Symfony\Component\DomCrawler\Crawler; - + // returns the attribute value for the first node $crawler->attr('class');