Automattic\WooCommerce\Vendor\Pelago\Emogrifier\HtmlProcessor

CssToAttributeConverter::mapBackgroundPropertyprivateWC 1.0

Method of the class: CssToAttributeConverter{}

No Hooks.

Returns

null. Nothing (null).

Usage

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

CssToAttributeConverter::mapBackgroundProperty() code WC 10.5.0

private function mapBackgroundProperty(\DOMElement $node, string $value): void
{
    // parse out the color, if any
    /** @var array<int, string> $styles */
    $styles = \explode(' ', $value, 2);
    $first = $styles[0];
    if (\is_numeric($first[0]) || \strncmp($first, 'url', 3) === 0) {
        return;
    }

    // as this is not a position or image, assume it's a color
    $node->setAttribute('bgcolor', $first);
}