public function SassRuleNode::extend in Sassy 7.3
Same name and namespace in other branches
- 7 phamlp/sass/tree/SassRuleNode.php \SassRuleNode::extend()
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
1 call to SassRuleNode::extend()
- SassRuleNode::render in phpsass/
tree/ SassRuleNode.php - Render this node and its children to CSS.
File
- phpsass/
tree/ SassRuleNode.php, line 119
Class
- SassRuleNode
- SassRuleNode class. Represents a CSS rule. @package PHamlP @subpackage Sass.tree
Code
public function extend() {
foreach ($this->root->extenders as $extendee => $extenders) {
if ($this
->isPsuedo($extendee)) {
$extendee = explode(':', $extendee);
$pattern = preg_quote($extendee[0]) . '((\\.[-\\w]+)*):' . preg_quote($extendee[1]);
}
else {
$pattern = preg_quote($extendee);
}
foreach (preg_grep('/' . $pattern . '/', $this->selectors) as $selector) {
foreach ($extenders as $extender) {
if (is_array($extendee)) {
$this->selectors[] = preg_replace('/(.*?)' . $pattern . '$/', "\\1{$extender}\\2", $selector);
}
elseif ($this
->isSequence($extender) || $this
->isSequence($selector)) {
$this->selectors = array_merge($this->selectors, $this
->mergeSequence($extender, $selector));
}
else {
$this->selectors[] = str_replace($extendee, $extender, $selector);
}
}
}
$this->selectors = array_unique($this->selectors);
}
}