Browse Source

ZF-8006: allow whitespace in child selector expressions

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20477 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 16 years ago
parent
commit
c09de5a777
2 changed files with 10 additions and 0 deletions
  1. 1 0
      library/Zend/Dom/Query/Css2Xpath.php
  2. 9 0
      tests/Zend/Dom/Query/Css2XpathTest.php

+ 1 - 0
library/Zend/Dom/Query/Css2Xpath.php

@@ -53,6 +53,7 @@ class Zend_Dom_Query_Css2Xpath
         }
 
         $paths    = array('//');
+        $path     = preg_replace('|\s+>\s+|', '>', $path);
         $segments = preg_split('/\s+/', $path);
         foreach ($segments as $key => $segment) {
             $pathSegment = self::_tokenize($segment);

+ 9 - 0
tests/Zend/Dom/Query/Css2XpathTest.php

@@ -183,6 +183,15 @@ class Zend_Dom_Query_Css2XpathTest extends PHPUnit_Framework_TestCase
         $test = Zend_Dom_Query_Css2Xpath::transform('tag#id @attribute');
         $this->assertEquals("//tag[@id='id']//@attribute", $test);
     }
+
+    /**
+     * @group ZF-8006
+     */
+    public function testShouldAllowWhitespaceInDescendentSelectorExpressions()
+    {
+        $test = Zend_Dom_Query_Css2Xpath::transform('child > leaf');
+        $this->assertEquals("//child/leaf", $test);
+    }
 }
 
 // Call Zend_Dom_Query_Css2XpathTest::main() if this source file is executed directly.