You are here

private function SassRuleNode::mergeSequence in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/tree/SassRuleNode.php \SassRuleNode::mergeSequence()

* Merges selector sequences *

Parameters

string the extender selector: * @param string selector to extend * @return array the merged sequences

1 call to SassRuleNode::mergeSequence()
SassRuleNode::extend in phamlp/sass/tree/SassRuleNode.php
* Extend this nodes selectors * $extendee is the subject of the @extend directive * $extender is the selector that contains the @extend directive * $selector a selector or selector sequence that is to be extended

File

phamlp/sass/tree/SassRuleNode.php, line 168

Class

SassRuleNode
SassRuleNode class. Represents a CSS rule. @package PHamlP @subpackage Sass.tree

Code

private function mergeSequence($extender, $selector) {
  $extender = explode(' ', $extender);
  $end = ' ' . array_pop($extender);
  $selector = explode(' ', $selector);
  array_pop($selector);
  $common = array();
  while ($extender[0] === $selector[0]) {
    $common[] = array_shift($selector);
    array_shift($extender);
  }
  $begining = !empty($common) ? join(' ', $common) . ' ' : '';
  return array(
    $begining . join(' ', $selector) . ' ' . join(' ', $extender) . $end,
    $begining . join(' ', $extender) . ' ' . join(' ', $selector) . $end,
  );
}