Skip to content

Commit

Permalink
[DomCrawler] Added support for <area> tags to be treated as links
Browse files Browse the repository at this point in the history
  • Loading branch information
shamess committed Feb 11, 2014
1 parent a1813cb commit 23acd26
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/DomCrawler/Link.php
Expand Up @@ -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>
*
Expand Down Expand Up @@ -188,7 +188,7 @@ protected function canonicalizePath($path)
*/
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));
}

Expand Down
12 changes: 12 additions & 0 deletions src/Symfony/Component/DomCrawler/Tests/LinkTest.php
Expand Up @@ -74,6 +74,18 @@ public function testGetUri($url, $currentUri, $expected)
$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(
Expand Down

0 comments on commit 23acd26

Please sign in to comment.