This commit is contained in:
1 parent
f7c532a648
commit
640bd67556
5801 files changed
+484532
-55857
No files matched your search
+22
-19
@@ -91,7 +91,7 @@ class NodeExtension extends AbstractExtension
|
||||
$subXpath->addNameTest();
|
||||
|
||||
if ($subXpath->getCondition()) {
|
||||
return $xpath->addCondition(sprintf('not(%s)', $subXpath->getCondition()));
|
||||
return $xpath->addCondition(\sprintf('not(%s)', $subXpath->getCondition()));
|
||||
}
|
||||
|
||||
return $xpath->addCondition('0');
|
||||
@@ -99,31 +99,34 @@ class NodeExtension extends AbstractExtension
|
||||
|
||||
public function translateMatching(Node\MatchingNode $node, Translator $translator): XPathExpr
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->selector);
|
||||
|
||||
foreach ($node->arguments as $argument) {
|
||||
$expr = $translator->nodeToXPath($argument);
|
||||
$expr->addNameTest();
|
||||
if ($condition = $expr->getCondition()) {
|
||||
$xpath->addCondition($condition, 'or');
|
||||
}
|
||||
}
|
||||
|
||||
return $xpath;
|
||||
return $this->translateMatchingOrSpecificityAdjustment($node->selector, $node->arguments, $translator);
|
||||
}
|
||||
|
||||
public function translateSpecificityAdjustment(Node\SpecificityAdjustmentNode $node, Translator $translator): XPathExpr
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->selector);
|
||||
return $this->translateMatchingOrSpecificityAdjustment($node->selector, $node->arguments, $translator);
|
||||
}
|
||||
|
||||
foreach ($node->arguments as $argument) {
|
||||
/**
|
||||
* @param array<Node\NodeInterface> $arguments
|
||||
*/
|
||||
private function translateMatchingOrSpecificityAdjustment(Node\NodeInterface $selector, array $arguments, Translator $translator): XPathExpr
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($selector);
|
||||
|
||||
$conditions = [];
|
||||
foreach ($arguments as $argument) {
|
||||
$expr = $translator->nodeToXPath($argument);
|
||||
$expr->addNameTest();
|
||||
if ($condition = $expr->getCondition()) {
|
||||
$xpath->addCondition($condition, 'or');
|
||||
if ('' !== $condition = $expr->getCondition()) {
|
||||
$conditions[] = $condition;
|
||||
}
|
||||
}
|
||||
|
||||
if ($conditions) {
|
||||
$xpath->addCondition(1 === \count($conditions) ? $conditions[0] : '('.implode(') or (', $conditions).')');
|
||||
}
|
||||
|
||||
return $xpath;
|
||||
}
|
||||
|
||||
@@ -151,11 +154,11 @@ class NodeExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
if ($node->getNamespace()) {
|
||||
$name = sprintf('%s:%s', $node->getNamespace(), $name);
|
||||
$name = \sprintf('%s:%s', $node->getNamespace(), $name);
|
||||
$safe = $safe && $this->isSafeName($node->getNamespace());
|
||||
}
|
||||
|
||||
$attribute = $safe ? '@'.$name : sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name));
|
||||
$attribute = $safe ? '@'.$name : \sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name));
|
||||
$value = $node->getValue();
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
|
||||
@@ -196,7 +199,7 @@ class NodeExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
if ($node->getNamespace()) {
|
||||
$element = sprintf('%s:%s', $node->getNamespace(), $element);
|
||||
$element = \sprintf('%s:%s', $node->getNamespace(), $element);
|
||||
$safe = $safe && $this->isSafeName($node->getNamespace());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user