You are here

public function Traverser::walk in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/masterminds/html5/src/HTML5/Serializer/Traverser.php \Masterminds\HTML5\Serializer\Traverser::walk()

Tell the traverser to walk the DOM.

Return value

resource $out Returns the output stream.

File

vendor/masterminds/html5/src/HTML5/Serializer/Traverser.php, line 65

Class

Traverser
Traverser for walking a DOM tree.

Namespace

Masterminds\HTML5\Serializer

Code

public function walk() {
  if ($this->dom instanceof \DOMDocument) {
    $this->rules
      ->document($this->dom);
  }
  elseif ($this->dom instanceof \DOMDocumentFragment) {

    // Document fragments are a special case. Only the children need to
    // be serialized.
    if ($this->dom
      ->hasChildNodes()) {
      $this
        ->children($this->dom->childNodes);
    }
  }
  elseif ($this->dom instanceof \DOMNodeList) {

    // If this is a NodeList of DOMDocuments this will not work.
    $this
      ->children($this->dom);
  }
  else {
    $this
      ->node($this->dom);
  }
  return $this->out;
}