Skip to content

Commit

Permalink
Show warning if @import is inside @media and if @charset is not at be…
Browse files Browse the repository at this point in the history
…gin of the file
  • Loading branch information
JakubOnderka committed Nov 5, 2011
1 parent 7641f00 commit 2a68077
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions lib/CSSTidy.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class CSSTidy
'animation-play-state' => 'CSS3.0',
'animation-delay' => 'CSS3.0',
'animation' => 'CSS3.0',

// Backgrounds
'background-size' => 'CSS3.0',
'background-origin' => 'CSS3.0',
'border-radius' => 'CSS3.0',
Expand Down Expand Up @@ -267,6 +267,9 @@ class CSSTidy
'user-select' => 'CSS3.0',
// Images
'image-rendering' => 'CSS3.0',
'image-resolution' => 'CSS3.0',
'image-orientation' => 'CSS3.0',

);

/** @var \CSSTidy\Optimise */
Expand Down Expand Up @@ -488,14 +491,29 @@ public function parse($string)
$subValues[0] = '"' . $subValues[0] . '"';
}


$status = 'is';

switch ($selector) {
case '@charset': $parsed->charset = $subValues[0];
case '@charset':
$parsed->charset = $subValues[0];
if (!empty($parsed->css) || !empty($parsed->import) || !empty($parsed->namespace)) {
$this->logger->log("@charset must be before anything", Logger::WARNING);
}
break;
case '@namespace': $parsed->namespace = implode(' ', $subValues);

case '@namespace':
$parsed->namespace = implode(' ', $subValues);
break;
case '@import': $parsed->import[] = implode(' ', $subValues);

case '@import':
$parsed->import[] = implode(' ', $subValues);
if (!empty($parsed->css)) {
$this->logger->log("@import must be before anything selectors", Logger::WARNING);
} else if (!empty($at)) {
$this->logger->log("@import cannot be inside @media", Logger::WARNING);
}

break;
}

Expand Down

0 comments on commit 2a68077

Please sign in to comment.