Exemplo n.º 1
0
 /**
  * 
  * compress selector
  */
 public function compressSelector()
 {
     if (empty($this->selectors)) {
         return true;
     }
     $selectors = array_values($this->selectors);
     $this->selectors = array();
     if (!$this->options['merge_selector'] || count($selectors) === 1) {
         return $this->output[] = $this->selectorToText($selectors);
     }
     $count = count($selectors);
     $result = array();
     $se = array();
     $flag = 0;
     for ($i = 0; $i < $count; $i++) {
         $item = $selectors[$i];
         if ($i === $count - 1) {
             $flag = 1;
         }
         if (empty($item['equal']) || $item['same_score']) {
             $se[] = $item;
         } else {
             $flag = 2;
         }
         if ($flag) {
             $se = $this->selectorsIntersect($se);
             if ($this->options['sort_selector']) {
                 $se = Fl_Css_Static::sortSelectors($se);
             }
             if ($flag === 2) {
                 $se[] = $item;
             }
             if (!empty($result)) {
                 array_unshift($se, array_pop($result));
             }
             $se = Fl_Css_Static::combineSameSelector($se);
             $se = $this->selectorsIntersect($se);
             $result = array_merge($result, $se);
             $se = array();
             $flag = 0;
         }
     }
     $this->output[] = $this->selectorToText($result);
 }