You are here

public function SassNode::addChild in Sassy 7.3

Same name and namespace in other branches
  1. 7 phamlp/sass/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 phpsass/tree/SassNode.php
Adds a warning to the node.

File

phpsass/tree/SassNode.php, line 123

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', $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;
  }
}