Automattic\WooCommerce\Vendor\Pelago\Emogrifier

CssInliner::copyUninlinableCssToStyleNode │ private │ WC 1.0

Applies $this->matchingUninlinableCssRules to $this->domDocument by placing them as CSS in a <style> element. If there are no uninlinable CSS rules to copy there, a <style> element will be created containing only the applicable at-rules from $parsedCss. If there are none of either, an empty <style> element will not be created.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->copyUninlinableCssToStyleNode( $parsedCss ): void;
$parsedCss(CssDocument) (обязательный)
This may contain various at-rules whose content CssInliner does not currently attempt to inline or process in any other way, such as @import, @font-face, @keyframes, etc., and which should precede the processed but found-to-be-uninlinable CSS placed in the <style> element. Note that CssInliner processes @media rules so that they can be ordered correctly with respect to other uninlinable rules; these will not be duplicated from $parsedCss.

Код CssInliner::copyUninlinableCssToStyleNode() WC 11.2.1

private function copyUninlinableCssToStyleNode(CssDocument $parsedCss): void
{
    $css = $parsedCss->renderNonConditionalAtRules();

    // avoid including unneeded class dependency if there are no rules
    if ($this->getMatchingUninlinableCssRules() !== []) {
        $cssConcatenator = new CssConcatenator();
        foreach ($this->getMatchingUninlinableCssRules() as $cssRule) {
            $cssConcatenator->append([$cssRule['selector']], $cssRule['declarationsBlock'], $cssRule['media']);
        }
        $css .= $cssConcatenator->getCss();
    }

    // avoid adding empty style element
    if ($css !== '') {
        $this->addStyleElementToDocument($css);
    }
}