Automattic\WooCommerce\Vendor\Symfony\Component\CssSelector\XPath

Translator::cssToXPathpublicWC 1.0

{@inheritdoc}

Method of the class: Translator{}

No Hooks.

Returns

null. Nothing (null).

Usage

$Translator = new Translator();
$Translator->cssToXPath( $cssExpr, $prefix ): string;
$cssExpr(string) (required)
.
$prefix(string)
.
Default: 'descendant-or-self::'

Translator::cssToXPath() code WC 10.8.1

public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string
{
    $selectors = $this->parseSelectors($cssExpr);

    /** @var SelectorNode $selector */
    foreach ($selectors as $index => $selector) {
        if (null !== $selector->getPseudoElement()) {
            throw new ExpressionErrorException('Pseudo-elements are not supported.');
        }

        $selectors[$index] = $this->selectorToXPath($selector, $prefix);
    }

    return implode(' | ', $selectors);
}