Explorar el Código

[CssSelector] removed an unneeded condition (taken care of afterward in the code) (closes #4269)

Fabien Potencier hace 13 años
padre
commit
d34383f10b

+ 0 - 5
src/Symfony/Component/CssSelector/Node/FunctionNode.php

@@ -250,11 +250,6 @@ class FunctionNode implements NodeInterface
             return array(0, 0);
         }
 
-        if (is_string($s)) {
-            // Happens when you just get a number
-            return array(0, $s);
-        }
-
         if ('odd' == $s) {
             return array(2, 1);
         }

+ 5 - 0
tests/Symfony/Tests/Component/CssSelector/Node/FunctionNodeTest.php

@@ -58,6 +58,11 @@ class FunctionNodeTest extends \PHPUnit_Framework_TestCase
         $function = new FunctionNode($element, ':', 'nth-child', $element2);
         $this->assertEquals("*/*[name() = 'h1' and (position() >= 1)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node');
 
+        // h1:nth-child(1)
+        $element2 = new ElementNode('*', new Token('Symbol', '2', -1));
+        $function = new FunctionNode($element, ':', 'nth-child', $element2);
+        $this->assertEquals("*/*[name() = 'h1' and (position() = 2)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node');
+
         // h1:nth-child(2n)
         $element2 = new ElementNode('*', new Token('Symbol', '2n', -1));
         $function = new FunctionNode($element, ':', 'nth-child', $element2);