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.
{} It's a method of the class: CssToAttributeConverter{}
No Hooks.
Return
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, \DOMElement $node );
- $property(string) (required)
- the name of the CSS property to map
- $value(string) (required)
- the value of the style rule to map
- \DOMElement $node (required)
- -
Code of CssToAttributeConverter::mapSimpleCssProperty() CssToAttributeConverter::mapSimpleCssProperty WC 5.0.0
private function mapSimpleCssProperty($property, $value, \DOMElement $node)
{
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;
}