Closed
Description
Currently crawler code is broken and filterXpath
does not take into account context in which it is executed in. Small code to reproduce issue:
<?php
require(__DIR__ . '/vendor/autoload.php');
$html = <<<HTML
<!DOCTYPE html>
<html lang="en">
<body>
<a href="/index.php?r=site/login">Login</a>
<form id="login-form" action="/index.php?r=site/login" method="post">
<button type="submit">Submit</button>
</form>
</body>
</html>
HTML;
$crawler = new Symfony\Component\DomCrawler\Crawler($html);
$newCrawler = $crawler->filterXPath("descendant-or-self::*[@id = 'login-form']");
var_dump($newCrawler->html());
//outputs form
var_dump($newCrawler->selectLink('Login')->html());
//outputs "Login", but there is no such link in form. It is only global
Code was broken by this commit. I checked out to commit before it and it works fine with giving me exception node list is empty
.