Automattic\WooCommerce\Vendor\Pelago\Emogrifier\Css

CssDocument::__constructpublicWC 1.0

Method of the class: CssDocument{}

No Hooks.

Returns

null. Nothing (null).

Usage

$CssDocument = new CssDocument();
$CssDocument->__construct( $css, $debug );
$css(string) (required)
.
$debug(true|false) (required)
If this is true, an exception will be thrown if invalid CSS is encountered. Otherwise the parser will try to do the best it can.

CssDocument::__construct() code WC 10.8.1

public function __construct(string $css, bool $debug)
{
    // CSS Parser currently throws exception with nested at-rules (like `@media`) in strict parsing mode
    $parserSettings = ParserSettings::create()->withLenientParsing(!$debug || $this->hasNestedAtRule($css));

    // CSS Parser currently throws exception with non-empty whitespace-only CSS in strict parsing mode, so `trim()`
    // @see https://github.com/sabberworm/PHP-CSS-Parser/issues/349
    $this->sabberwormCssDocument = (new CssParser(\trim($css), $parserSettings))->parse();
}