Skip to content

Commit

Permalink
Merge pull request #8 from luislarrateguy/master
Browse files Browse the repository at this point in the history
fixing issue with attributes that had spaces in their values
  • Loading branch information
Darhazer committed Oct 20, 2014
2 parents fa8b0d1 + 85a14bd commit 8f7c606
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions selector.inc
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ function selector_to_xpath($selector) {
$selector = preg_replace('/\s*~\s*/', '~', $selector);
$selector = preg_replace('/\s*\+\s*/', '+', $selector);
$selector = preg_replace('/\s*,\s*/', ',', $selector);
$selectors = preg_split("/\s+/", $selector);
$selectors = preg_split("/\s+(?![^\[]+\])/", $selector);

foreach ($selectors as &$selector) {
// ,
$selector = preg_replace('/\s*,\s*/', '|descendant-or-self::', $selector);
Expand Down
2 changes: 2 additions & 0 deletions test.selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ function test($selector, $expected) {
test('[id]', 'descendant-or-self::*[@id]');
test('[id=bar]', 'descendant-or-self::*[@id="bar"]');
test('foo[id=bar]', 'descendant-or-self::foo[@id="bar"]');
test('[style=color: red; border: 1px solid black;]', 'descendant-or-self::*[@style="color: red; border: 1px solid black;"]');
test('foo[style=color: red; border: 1px solid black;]', 'descendant-or-self::foo[@style="color: red; border: 1px solid black;"]');
test(':button', 'descendant-or-self::input[@type="button"]');
test('textarea', 'descendant-or-self::textarea');
test(':submit', 'descendant-or-self::input[@type="submit"]');
Expand Down

0 comments on commit 8f7c606

Please sign in to comment.