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

Commit ec2c66c

Browse files
committed
Merge branch 'hotfix/23'
Close #23
2 parents 3c63c60 + 0801573 commit ec2c66c

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ All notable changes to this project will be documented in this file, in reverse
3434
tokenizer marks multiple words within attribute values in order to be
3535
more robust.
3636

37+
- [#23](https://github.com/zendframework/zend-dom/pull/23) fixes an issue with
38+
how descendant selectors work, ensuring spaces may be used around the `>`
39+
operator.
40+
3741
## 2.7.0 - 2018-03-27
3842

3943
### Added

src/Document/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function ($matches) use ($placeholder) {
100100
);
101101

102102
$paths = ['//'];
103-
$path = preg_replace('|\s+>\s+|', '>', $path);
103+
$path = preg_replace('|\s*>\s*|', '>', $path);
104104
$segments = preg_split('/\s+/', $path);
105105
$segments = str_replace($placeholder, ' ', $segments);
106106

test/Document/QueryTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,26 @@ public function testShouldAllowMatchingOfAttributeValues()
134134
$this->assertEquals("//tag[@id='id']//@attribute", $test);
135135
}
136136

137+
public function descendantSelector()
138+
{
139+
yield 'space before' => ['child >leaf'];
140+
yield 'space after' => ['child> leaf'];
141+
yield 'no spaces' => ['child>leaf'];
142+
yield 'with spaces' => ['child > leaf'];
143+
yield 'more spaces' => ['child > leaf'];
144+
}
145+
137146
/**
138147
* @group ZF-8006
148+
*
149+
* @dataProvider descendantSelector
150+
*
151+
* @param string $path
139152
*/
140-
public function testShouldAllowWhitespaceInDescendantSelectorExpressions()
153+
public function testShouldAllowWhitespaceInDescendantSelectorExpressions($path)
141154
{
142-
$test = Query::cssToXpath('child > leaf');
143-
$this->assertEquals("//child/leaf", $test);
155+
$test = Query::cssToXpath($path);
156+
$this->assertEquals('//child/leaf', $test);
144157
}
145158

146159
/**

0 commit comments

Comments
 (0)