Automattic\WooCommerce\Vendor\Pelago\Emogrifier
CssInliner::removeImportantAnnotationFromNodeInlineStyle
Removes the "!important" annotations out of the inline style declarations, eventually by rearranging declarations. Rearranging needed when !important shorthand properties are followed by some of their not !important expanded-version properties. For example "font: 12px serif !important; font-size: 13px;" must be reordered to "font-size: 13px; font: 12px serif;" in order to remain correct.
Метод класса: CssInliner{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->removeImportantAnnotationFromNodeInlineStyle( $node ): void;
- $node(DOMElement) (обязательный)
- .
Код CssInliner::removeImportantAnnotationFromNodeInlineStyle() CssInliner::removeImportantAnnotationFromNodeInlineStyle WC 10.4.3
private function removeImportantAnnotationFromNodeInlineStyle(\DOMElement $node): void
{
$style = $node->getAttribute('style');
$inlineStyleDeclarations = (new DeclarationBlockParser())->parse((bool) $style ? $style : '');
/** @var array<string, string> $regularStyleDeclarations */
$regularStyleDeclarations = [];
/** @var array<string, string> $importantStyleDeclarations */
$importantStyleDeclarations = [];
foreach ($inlineStyleDeclarations as $property => $value) {
if ($this->attributeValueIsImportant($value)) {
$importantStyleDeclarations[$property]
= (new Preg())->throwExceptions($this->debug)->replace('/\\s*+!\\s*+important$/i', '', $value);
} else {
$regularStyleDeclarations[$property] = $value;
}
}
$inlineStyleDeclarationsInNewOrder = \array_merge($regularStyleDeclarations, $importantStyleDeclarations);
$node->setAttribute(
'style',
$this->generateStyleStringFromSingleDeclarationsArray($inlineStyleDeclarationsInNewOrder)
);
}