Skip to content

Commit 8fc5aeb

Browse files
committed
[CssSelector] Support *:only-of-type
1 parent 2044ba8 commit 8fc5aeb

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/Symfony/Component/CssSelector/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
7+
* Added support for `*:only-of-type`
8+
49
2.8.0
510
-----
611

src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ public function getHtmlIdsTestData()
308308
['li div:only-child', ['li-div']],
309309
['div *:only-child', ['li-div', 'foobar-span']],
310310
['p:only-of-type', ['paragraph']],
311+
[':only-of-type', ['html', 'li-div', 'foobar-span', 'paragraph']],
312+
['div#foobar-div :only-of-type', ['foobar-span']],
311313
['a:empty', ['name-anchor']],
312314
['a:EMpty', ['name-anchor']],
313315
['li:empty', ['third-li', 'fourth-li', 'fifth-li', 'sixth-li']],

src/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,10 @@ public function translateOnlyChild(XPathExpr $xpath): XPathExpr
100100
->addCondition('last() = 1');
101101
}
102102

103-
/**
104-
* @throws ExpressionErrorException
105-
*/
106103
public function translateOnlyOfType(XPathExpr $xpath): XPathExpr
107104
{
108105
$element = $xpath->getElement();
109106

110-
if ('*' === $element) {
111-
throw new ExpressionErrorException('"*:only-of-type" is not implemented.');
112-
}
113-
114107
return $xpath->addCondition(sprintf('count(preceding-sibling::%s)=0 and count(following-sibling::%s)=0', $element, $element));
115108
}
116109

0 commit comments

Comments
 (0)
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