Automattic\WooCommerce\EmailEditorVendor\Symfony\Component\CssSelector\XPath\Extension
NodeExtension::translateAttribute
Метод класса: NodeExtension{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$NodeExtension = new NodeExtension(); $NodeExtension->translateAttribute( $node, $translator ): XPathExpr;
- $node([Node\AttributeNode]()) (обязательный)
- .
- $translator(Translator) (обязательный)
- .
Код NodeExtension::translateAttribute() NodeExtension::translateAttribute WC 11.2.2
public function translateAttribute(Node\AttributeNode $node, Translator $translator): XPathExpr
{
$name = $node->getAttribute();
$safe = $this->isSafeName($name);
if ($this->hasFlag(self::ATTRIBUTE_NAME_IN_LOWER_CASE)) {
$name = strtolower($name);
}
if ($node->getNamespace()) {
$name = sprintf('%s:%s', $node->getNamespace(), $name);
$safe = $safe && $this->isSafeName($node->getNamespace());
}
$attribute = $safe ? '@'.$name : sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name));
$value = $node->getValue();
$xpath = $translator->nodeToXPath($node->getSelector());
if ($this->hasFlag(self::ATTRIBUTE_VALUE_IN_LOWER_CASE)) {
$value = strtolower($value);
}
return $translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value);
}