Automattic\WooCommerce\Vendor\Pelago\Emogrifier
CssInliner::normalizeStyleAttributes
Normalizes the value of the "style" attribute and saves it.
Method of the class: CssInliner{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->normalizeStyleAttributes( $node ): void;
- $node(DOMElement) (required)
- .
CssInliner::normalizeStyleAttributes() CssInliner::normalizeStyleAttributes code WC 10.4.3
private function normalizeStyleAttributes(\DOMElement $node): void
{
$declarationBlockParser = new DeclarationBlockParser();
$normalizedOriginalStyle = (new Preg())->throwExceptions($this->debug)->replaceCallback(
'/-{0,2}+[_a-zA-Z][\\w\\-]*+(?=:)/S',
/** @param array<array-key, string> $propertyNameMatches */
static function (array $propertyNameMatches) use ($declarationBlockParser): string {
return $declarationBlockParser->normalizePropertyName($propertyNameMatches[0]);
},
$node->getAttribute('style')
);
// In order to not overwrite existing style attributes in the HTML, we have to save the original HTML styles.
$nodePath = $node->getNodePath();
if (\is_string($nodePath) && !isset($this->styleAttributesForNodes[$nodePath])) {
$this->styleAttributesForNodes[$nodePath] = $declarationBlockParser->parse($normalizedOriginalStyle);
$this->visitedNodes[$nodePath] = $node;
}
$node->setAttribute('style', $normalizedOriginalStyle);
}