Exemplo n.º 1
0
 /**
  * Finds a selector
  *
  * @param ILess_Node $selector
  * @param ILess_Node_Ruleset $self
  * @param ILess_Environment $env
  * @return array
  */
 public function find(ILess_Node $selector, ILess_Environment $env, ILess_Node_Ruleset $self = null)
 {
     $key = $selector->toCSS($env);
     if (!$self) {
         $self = $this;
     }
     if (!array_key_exists($key, $this->lookups)) {
         $this->lookups[$key] = array();
         foreach ($this->rules as $rule) {
             if ($rule === $self) {
                 continue;
             }
             if ($rule instanceof ILess_Node_Ruleset || $rule instanceof ILess_Node_MixinDefinition) {
                 foreach ($rule->selectors as $ruleSelector) {
                     $match = $selector->match($ruleSelector);
                     if ($match) {
                         if (count($selector->elements) > $match) {
                             $this->lookups[$key] = array_merge($this->lookups[$key], $rule->find(new ILess_Node_Selector(array_slice($selector->elements, $match)), $env, $self));
                         } else {
                             $this->lookups[$key][] = $rule;
                         }
                         break;
                     }
                 }
             }
         }
     }
     return $this->lookups[$key];
 }