diff --git a/src/Symfony/Component/CssSelector/CHANGELOG.md b/src/Symfony/Component/CssSelector/CHANGELOG.md index 4061ff20c3d2a..de81fa2e7d437 100644 --- a/src/Symfony/Component/CssSelector/CHANGELOG.md +++ b/src/Symfony/Component/CssSelector/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.4.0 +----- + + * Added support for `*:only-of-type` + 2.8.0 ----- diff --git a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php index a718fbd6f2e4c..568bb42716715 100644 --- a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php +++ b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php @@ -308,6 +308,8 @@ public function getHtmlIdsTestData() ['li div:only-child', ['li-div']], ['div *:only-child', ['li-div', 'foobar-span']], ['p:only-of-type', ['paragraph']], + [':only-of-type', ['html', 'li-div', 'foobar-span', 'paragraph']], + ['div#foobar-div :only-of-type', ['foobar-span']], ['a:empty', ['name-anchor']], ['a:EMpty', ['name-anchor']], ['li:empty', ['third-li', 'fourth-li', 'fifth-li', 'sixth-li']], diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php index ee53085fd03de..a50b0486ac8e2 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php @@ -100,17 +100,10 @@ public function translateOnlyChild(XPathExpr $xpath): XPathExpr ->addCondition('last() = 1'); } - /** - * @throws ExpressionErrorException - */ public function translateOnlyOfType(XPathExpr $xpath): XPathExpr { $element = $xpath->getElement(); - if ('*' === $element) { - throw new ExpressionErrorException('"*:only-of-type" is not implemented.'); - } - return $xpath->addCondition(sprintf('count(preceding-sibling::%s)=0 and count(following-sibling::%s)=0', $element, $element)); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy