Skip to content

[DomCrawler] Inconsistency between children and parents #26432

Closed
@dunglas

Description

@dunglas
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version all

According to the documentation:

Get all the child or parent nodes:

$crawler->filter('body')->children();
$crawler->filter('body > p')->parents();

However, children() returns only direct children (not grandchildren...), while parents() returns all ancestors (including grandparents...).

Maybe it's more a docs issue than a code issue? Anyway it looks weird to me that methods with similar names have a different behavior.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions