You are here

private function CSSCompression_Selectors::idAttribute in Advanced CSS/JS Aggregation 7

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

Convert [id=blah] attribute selectors into id form selector (#blah)

Parameters

(string) selector: CSS Selector:

1 call to CSSCompression_Selectors::idAttribute()
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 147

Class

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

Code

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

    // Don't convert if space found (not valid hash selector)
    if (strpos($match[1][0], ' ') !== false) {
      $pos = $match[0][1] + strlen($match[0][0]);
      continue;
    }
    $selector = substr_replace($selector, '#' . $match[1][0], $match[0][1], strlen($match[0][0]));
    $pos = $match[0][1] + strlen($match[1][0]) + 1;
  }
  return $selector;
}