You are here

public function SassNode::addChild in Sassy 7

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

* Adds a child to this node. *

Return value

SassNode the child to add

1 call to SassNode::addChild()
SassNode::addWarning in phamlp/sass/tree/SassNode.php
* Adds a warning to the node. *

File

phamlp/sass/tree/SassNode.php, line 120

Class

SassNode
SassNode class. Base class for all Sass nodes. @package PHamlP @subpackage Sass.tree

Code

public function addChild($child) {
  if ($child instanceof SassElseNode) {
    if (!$this->lastChild instanceof SassIfNode) {
      throw new SassException('@else(if) directive must come after @(else)if', array(), $child);
    }
    $this->lastChild
      ->addElse($child);
  }
  else {
    $this->children[] = $child;
    $child->parent = $this;
    $child->root = $this->root;
  }

  // The child will have children if a debug node has been added
  foreach ($child->children as $grandchild) {
    $grandchild->root = $this->root;
  }
}