Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merged 2.0

  • Loading branch information...
commit 3355a84f0ffb7cc6c4d89da89edbc181d3582ab1 2 parents 0f355f5 + 6a8f139
@fabpot fabpot authored
View
5 CssSelector.php
@@ -153,6 +153,11 @@ private function parseSelector($stream)
} elseif (in_array($peek, array('+', '>', '~'))) {
// A combinator
$combinator = (string) $stream->next();
+
+ // Ignore optional whitespace after a combinator
+ while (' ' == $stream->peek()) {
+ $stream->next();
+ }
} else {
$combinator = ' ';
}
View
5 Node/FunctionNode.php
@@ -250,11 +250,6 @@ protected function parseSeries($s)
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);
}
View
2  README.md
@@ -16,7 +16,7 @@ Resources
This component is a port of the Python lxml library, which is copyright Infrae
and distributed under the BSD license.
-Current code is a port of http://codespeak.net/svn/lxml/trunk/src/lxml/cssselect.py@71545
+Current code is a port of https://github.com/SimonSapin/cssselect@fd2e70
You can run the unit tests with the following command:
View
2  Tests/CssSelectorTest.php
@@ -64,6 +64,8 @@ public function getCssSelectors()
array('h1 .foo', "h1/descendant::*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"),
array('h1 #foo', "h1/descendant::*[@id = 'foo']"),
array('h1 [class*=foo]', "h1/descendant::*[contains(@class, 'foo')]"),
+ array('div>.foo', "div/*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"),
+ array('div > .foo', "div/*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"),
);
}
}
View
5 Tests/Node/FunctionNodeTest.php
@@ -58,6 +58,11 @@ public function testToXpath()
$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);
Please sign in to comment.
Something went wrong with that request. Please try again.