Automattic\WooCommerce\Vendor\Pelago\Emogrifier

CssInliner::normalizeStyleAttributes │ private │ WC 1.0

Normalizes the value of the "style" attribute and saves it.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// private - только в коде основоного (родительского) класса
$result = $this->normalizeStyleAttributes( $node ): void;
$node(DOMElement) (обязательный)
.

Код CssInliner::normalizeStyleAttributes() WC 11.2.1

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