Skip to content

[DomCrawler] Selecting attribute 2.8 BC break  #16417

Closed
@boekkooi

Description

@boekkooi

As I was updating one of my packages I noticed that the test where all failing with 2.8.
After some research I found out that the DomCrawler was not working as expected when selecting a attribute using //div/@id.

I created the following test for CrawlerTest.php that shows the break:

    public function testFilterXPathAttribute()
    {
        $crawler = $this->createTestCrawler();

        $formIds = $crawler->filterXPath('//form/@action');
        $this->assertCount(1, $formIds, '->filterXPath() finds node attributes');
        $this->assertEquals('foo', $formIds->html(), '->filterXPath() returns the html of the found attribute');

        $divIds = $crawler->filterXPath('//form/@id');
        $this->assertCount(1, $divIds, '->filterXPath() finds node attributes');
        $this->assertEquals('FooFormId', $divIds->html(), '->filterXPath() returns the html of the first attribute');
    }

This BC break was introduced by #16058. (commit 9f362a1)

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