Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge 00a36de into 6ff0f94
Browse files Browse the repository at this point in the history
  • Loading branch information
MidnightDesign committed Apr 6, 2018
2 parents 6ff0f94 + 00a36de commit 4a433c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Document/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static function cssToXpath($path)

// Arbitrary attribute value contains whitespace
$path = preg_replace_callback(
'/\[\S+["\'](.+)["\']\]/',
'/\[\S+?["\'](.+?)["\']\]/',
function ($matches) {
return str_replace($matches[1], preg_replace('/\s+/', '\s', $matches[1]), $matches[0]);
},
Expand Down
6 changes: 6 additions & 0 deletions test/Document/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,10 @@ public function testCanTransformWithAttributeAndDot()
$test = Query::cssToXpath('a[@href="http://example.com"]');
$this->assertEquals("//a[@href='http://example.com']", $test);
}

public function testTransformNestedAttributeSelectors()
{
$test = Query::cssToXpath('select[name="foo"] option[selected="selected"]');
$this->assertEquals("//select[@name='foo']//option[@selected='selected']", $test);
}
}

0 comments on commit 4a433c0

Please sign in to comment.