Automattic\WooCommerce\Vendor\Pelago\Emogrifier\HtmlProcessor

CssToAttributeConverter::mapSimpleCssProperty │ private │ WC 1.0

Looks up the CSS property in the mapping table and maps it if it matches the conditions.

Метод класса: CssToAttributeConverter{}

Хуков нет.

Возвращает

bool. true if the property can be mapped using the simple mapping table

Использование

// private - только в коде основоного (родительского) класса
$result = $this->mapSimpleCssProperty( $property, $value, $node ): bool;
$property(строка) (обязательный)
the name of the CSS property to map.
$value(строка) (обязательный)
the value of the style rule to map.
$node(DOMElement) (обязательный)
node to apply styles to.

Код CssToAttributeConverter::mapSimpleCssProperty() WC 11.2.1

private function mapSimpleCssProperty(string $property, string $value, \DOMElement $node): bool
{
    if (!isset($this->cssToHtmlMap[$property])) {
        return false;
    }

    $mapping = $this->cssToHtmlMap[$property];
    $nodesMatch = !isset($mapping['nodes']) || \in_array($node->nodeName, $mapping['nodes'], true);
    $valuesMatch = !isset($mapping['values']) || \in_array($value, $mapping['values'], true);
    $canBeMapped = $nodesMatch && $valuesMatch;
    if ($canBeMapped) {
        $node->setAttribute($mapping['attribute'], $value);
    }

    return $canBeMapped;
}