Skip to content

Commit

Permalink
[+]: "reset css rules when new css is set" (revert the revert)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Moelleken committed Sep 29, 2015
1 parent 125f52b commit a83980a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/CssToInlineStyles.php
Expand Up @@ -97,6 +97,12 @@ class CssToInlineStyles
*/
private $excludeConditionalInlineStylesBlock = true;

/**
* Whether css was already processed and there's no need to do it again
* @var bool
*/
private $isCssProcessed = false;

/**
* Exclude media queries from "$this->css" and keep media queries for inline-styles blocks
*
Expand Down Expand Up @@ -141,6 +147,8 @@ public function setHTML($html)
public function setCSS($css)
{
$this->css = (string)$css;

$this->isCssProcessed = false;
}

/**
Expand Down Expand Up @@ -189,7 +197,9 @@ public function convert($outputXHTML = false)
}

// process css
$this->processCSS();
if (!$this->isCssProcessed) {
$this->processCSS();
}

// create new DOMDocument
$document = $this->createDOMDocument();
Expand Down Expand Up @@ -343,6 +353,8 @@ private function processCSS()
if (0 !== count($this->cssRules)) {
usort($this->cssRules, array(__CLASS__, 'sortOnSpecificity'));
}

$this->isCssProcessed = true;
}

/**
Expand Down

0 comments on commit a83980a

Please sign in to comment.