Automattic\WooCommerce\Vendor\Pelago\Emogrifier\HtmlProcessor

CssToAttributeConverter::mapSimpleCssPropertyprivateWC 1.0

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

Method of the class: CssToAttributeConverter{}

No Hooks.

Returns

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

Usage

// private - for code of main (parent) class only
$result = $this->mapSimpleCssProperty( $property, $value, $node ): bool;
$property(string) (required)
the name of the CSS property to map.
$value(string) (required)
the value of the style rule to map.
$node(DOMElement) (required)
node to apply styles to.

CssToAttributeConverter::mapSimpleCssProperty() code WC 10.5.0

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;
}