Permalink
Browse files

[CssSelector] fixed BC break

  • Loading branch information...
1 parent b7eb8da commit 2e236423ba6fb3d39ad69a56e4b54a54d0e5480f @fabpot fabpot committed Mar 23, 2013
Showing with 21 additions and 4 deletions.
  1. +20 −3 src/Symfony/Component/CssSelector/CssSelector.php
  2. +1 −1 src/Symfony/Component/CssSelector/README.md
@@ -33,24 +33,25 @@
*/
class CssSelector
{
+ private static $html = true;
+
/**
* Translates a CSS expression to its XPath equivalent.
* Optionally, a prefix can be added to the resulting XPath
* expression with the $prefix parameter.
*
* @param mixed $cssExpr The CSS expression.
* @param string $prefix An optional prefix for the XPath expression.
- * @param boolean $html Enables HTML extension.
*
* @return string
*
* @api
*/
- public static function toXPath($cssExpr, $prefix = 'descendant-or-self::', $html = true)
+ public static function toXPath($cssExpr, $prefix = 'descendant-or-self::')
{
$translator = new Translator();
- if ($html) {
+ if (self::$html) {
$translator->registerExtension(new HtmlExtension($translator));
}
@@ -63,4 +64,20 @@ public static function toXPath($cssExpr, $prefix = 'descendant-or-self::', $html
return $translator->cssToXPath($cssExpr, $prefix);
}
+
+ /**
+ * Enables the HTML extension.
+ */
+ public static function enableHtmlExtension()
+ {
+ self::$html = true;
+ }
+
+ /**
+ * Disables the HTML extension.
+ */
+ public static function disableHtmlExtension()
+ {
+ self::$html = false;
+ }
}
@@ -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 https://github.com/SimonSapin/cssselect@fd2e70
+Current code is a port of https://github.com/SimonSapin/cssselect@v0.7.1
You can run the unit tests with the following command:

0 comments on commit 2e23642

Please sign in to comment.