Menu

#27 media query not parsed correctly

v1.0 (example)
open
nobody
5
2015-02-22
2014-05-29
bjoerne
No

The following media query is transformed into the following result:

@media (min-width: 600px) {
  .sample {
    display: block;
  }
}

Result:

@media min-width 600px {
.sample {
display:block;
}
}

The media query is broken. I had a look in to the source code and think that the colon and the braces aren't handled inside the media query.

        case 'at':
        if(csstidy::is_token($string,$i))
        {
            if($string{$i} == '/' && @$string{$i+1} == '*')
            {
                $this->status = 'ic'; ++$i;
                $this->from = 'at';
            }
            elseif($string{$i} == '{')
            {
                $this->status = 'is';
                $this->_add_token(AT_START, $this->at);
            }
            elseif($string{$i} == ',')
            {
                $this->at = trim($this->at).',';
            }
            elseif($string{$i} == '\\')
            {
                $this->at .= $this->_unicode($string,$i);
            }
        }

They are just ignored and are not part of the result.

Here are my options:

$options = array(
    'remove_bslash' => false,
    'compress_colors' => false,
    'compress_font-weight' => false,
    'lowercase_s' => false,
    'optimise_shorthands' => 1,
    'remove_last_;' => false,
    'case_properties' => 1,
    'sort_properties' => false,
    'sort_selectors' => false,
    'merge_selectors' => 2,
    'discard_invalid_properties' => false,
    'css_level' => 'CSS2.1',
    'preserve_css' => true,
    'timestamp' => false,
    'template' => 'default'
);

Discussion

  • bjoerne

    bjoerne - 2014-05-29

    Version 1.3

     
    • Agris

      Agris - 2014-10-28

      Maybe this will help to someone:

      case 'at':
      if(csstidy::is_token($string,$i))
      {
      if($string{$i} == '/' && @$string{$i+1} == '*')
      {
      $this->status = 'ic'; ++$i;
      $this->from = 'at';
      }
      elseif($string{$i} == '{')
      {
      $this->status = 'is';
      $this->_add_token(AT_START, $this->at);
      }
      elseif($string{$i} == ',')
      {
      $this->at = trim($this->at).',';
      }
      elseif($string{$i} == '\')
      {
      $this->at .= $this->_unicode($string,$i);
      }
      #Change: accept media queries
      elseif($string{$i} == '(' || $string{$i} == ')' || $string{$i} == ':')
      {
      $this->at .= $string{$i};
      }

      }

       

Log in to post a comment.

MongoDB Logo MongoDB