Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed Jul 20, 2014
1 parent 0d7842b commit 342172c
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions CssToInlineStyles.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,40 +84,6 @@ public function __construct($html = null, $css = null)
if($css !== null) $this->setCSS($css);
}

/**
* Calculate the specifity for the CSS-selector
*
* @return int
* @param string $selector The selector to calculate the specifity for.
*/
private function calculateCSSSpecifity($selector)
{
// cleanup selector
$selector = str_replace(array('>', '+'), array(' > ', ' + '), $selector);

// init var
$specifity = 0;

// split the selector into chunks based on spaces
$chunks = explode(' ', $selector);

// loop chunks
foreach ($chunks as $chunk) {
// an ID is important, so give it a high specifity
if(strstr($chunk, '#') !== false) $specifity += 100;

// classes are more important than a tag, but less important then an ID
elseif(strstr($chunk, '.')) $specifity += 10;

// anything else isn't that important
else $specifity += 1;
}

// return
return $specifity;
}


/**
* Cleanup the generated HTML
*
Expand Down

0 comments on commit 342172c

Please sign in to comment.