You are here

private function CSSCompression_Selectors::classAttribute in Advanced CSS/JS Aggregation 6

Same name and namespace in other branches
  1. 7 advagg_css_compress/css-compressor-3.x/src/lib/Selectors.inc \CSSCompression_Selectors::classAttribute()

Convert [class=blah] attribute selectors into class form selector (.blah)

Parameters

(string) selector: CSS Selector:

1 call to CSSCompression_Selectors::classAttribute()
CSSCompression_Selectors::selectors in advagg_css_compress/css-compressor-3.x/src/lib/Selectors.inc
Selector specific optimizations

File

advagg_css_compress/css-compressor-3.x/src/lib/Selectors.inc, line 168

Class

CSSCompression_Selectors
CSS Compressor [VERSION] [DATE] Corey Hart @ http://www.codenothing.com

Code

private function classAttribute($selector) {
  $pos = 0;
  while (preg_match($this->rclassattr, $selector, $match, PREG_OFFSET_CAPTURE, $pos)) {

    // Don't convert if prescense of dot separator found
    if (strpos($match[1][0], '.') !== false) {
      $pos = $match[0][1] + strlen($match[0][0]);
      continue;
    }
    $replace = '.' . preg_replace($this->rescapedspace, ".", $match[1][0]);
    $selector = substr_replace($selector, $replace, $match[0][1], strlen($match[0][0]));
    $pos = $match[0][1] + strlen($match[1][0]) + 1;
  }
  return $selector;
}