Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Symfony
css-selector
Commits
692bb940
Commit
692bb940
authored
5 years ago
by
Jakub Zalas
Browse files
Options
Download
Email Patches
Plain Diff
[CssSelector] Support *:only-of-type pseudo class selector
parent
1f8fa58d
6.2
4.4
5.0
5.1
5.2
5.3
5.4
6.0
6.1
6.3
v6.2.7
v6.2.5
v6.2.3
v6.2.0
v6.2.0-RC1
v6.2.0-BETA1
v6.1.11
v6.1.9
v6.1.3
v6.1.0
v6.1.0-RC1
v6.1.0-BETA1
v6.0.19
v6.0.17
v6.0.11
v6.0.3
v6.0.2
v6.0.1
v6.0.0
v6.0.0-RC1
v6.0.0-BETA1
v5.4.21
v5.4.19
v5.4.17
v5.4.11
v5.4.3
v5.4.2
v5.4.0
v5.4.0-RC1
v5.4.0-BETA1
v5.3.14
v5.3.4
v5.3.0
v5.3.0-RC1
v5.3.0-BETA1
v5.2.12
v5.2.10
v5.2.9
v5.2.7
v5.2.4
v5.2.3
v5.2.2
v5.2.1
v5.2.0
v5.2.0-RC2
v5.2.0-RC1
v5.2.0-BETA3
v5.2.0-BETA2
v5.2.0-BETA1
v5.1.11
v5.1.10
v5.1.9
v5.1.8
v5.1.7
v5.1.6
v5.1.5
v5.1.4
v5.1.3
v5.1.2
v5.1.1
v5.1.0
v5.1.0-RC2
v5.1.0-RC1
v5.1.0-BETA1
v5.0.11
v5.0.10
v5.0.9
v5.0.8
v5.0.7
v5.0.6
v5.0.5
v5.0.4
v5.0.3
v5.0.2
v5.0.1
v5.0.0
v5.0.0-RC1
v5.0.0-BETA2
v5.0.0-BETA1
v4.4.44
v4.4.37
v4.4.27
v4.4.25
v4.4.24
v4.4.22
v4.4.20
v4.4.19
v4.4.18
v4.4.17
v4.4.16
v4.4.15
v4.4.14
v4.4.13
v4.4.12
v4.4.11
v4.4.10
v4.4.9
v4.4.8
v4.4.7
v4.4.6
v4.4.5
v4.4.4
v4.4.3
v4.4.2
v4.4.1
v4.4.0
v4.4.0-RC1
v4.4.0-BETA2
v4.4.0-BETA1
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+5
-0
CHANGELOG.md
Tests/XPath/TranslatorTest.php
+2
-0
Tests/XPath/TranslatorTest.php
XPath/Extension/PseudoClassExtension.php
+0
-7
XPath/Extension/PseudoClassExtension.php
with
7 additions
and
7 deletions
+7
-7
CHANGELOG.md
+
5
-
0
View file @
692bb940
CHANGELOG
=========
4.
4.0
-----
*
Added support for
`*:only-of-type`
2.
8.0
-----
...
...
This diff is collapsed.
Click to expand it.
Tests/XPath/TranslatorTest.php
+
2
-
0
View file @
692bb940
...
...
@@ -308,6 +308,8 @@ HTML
[
'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'
]],
...
...
This diff is collapsed.
Click to expand it.
XPath/Extension/PseudoClassExtension.php
+
0
-
7
View file @
692bb940
...
...
@@ -100,17 +100,10 @@ class PseudoClassExtension extends AbstractExtension
->
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
));
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets