[DomCrawler] Added support for <area> tags to be treated as links
This commit is contained in:
parent
a1813cb57a
commit
23acd26d4a
@ -12,7 +12,7 @@
|
||||
namespace Symfony\Component\DomCrawler;
|
||||
|
||||
/**
|
||||
* Link represents an HTML link (an HTML a tag).
|
||||
* Link represents an HTML link (an HTML a or area tag).
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
@ -188,7 +188,7 @@ class Link
|
||||
*/
|
||||
protected function setNode(\DOMNode $node)
|
||||
{
|
||||
if ('a' != $node->nodeName) {
|
||||
if ('a' != $node->nodeName && 'area' != $node->nodeName) {
|
||||
throw new \LogicException(sprintf('Unable to click on a "%s" tag.', $node->nodeName));
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,18 @@ class LinkTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($expected, $link->getUri());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getGetUriTests
|
||||
*/
|
||||
public function testGetUriOnArea($url, $currentUri, $expected)
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadHTML(sprintf('<html><map><area href="%s" /></map></html>', $url));
|
||||
$link = new Link($dom->getElementsByTagName('area')->item(0), $currentUri);
|
||||
|
||||
$this->assertEquals($expected, $link->getUri());
|
||||
}
|
||||
|
||||
public function getGetUriTests()
|
||||
{
|
||||
return array(
|
||||
|
Reference in New Issue
Block a user