Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DOMTreeBuilder.php

function DOMTreeBuilder::__construct

File

vendor/masterminds/html5/src/HTML5/Parser/DOMTreeBuilder.php, line 165

Class

DOMTreeBuilder
Create an HTML5 DOM tree from events.

Namespace

Masterminds\HTML5\Parser

Code

public function __construct($isFragment = false, array $options = array()) {
    $this->options = $options;
    if (isset($options[self::OPT_TARGET_DOC])) {
        $this->doc = $options[self::OPT_TARGET_DOC];
    }
    else {
        $impl = new \DOMImplementation();
        // XXX:
        // Create the doctype. For now, we are always creating HTML5
        // documents, and attempting to up-convert any older DTDs to HTML5.
        $dt = $impl->createDocumentType('html');
        // $this->doc = \DOMImplementation::createDocument(NULL, 'html', $dt);
        $this->doc = $impl->createDocument(null, '', $dt);
        $this->doc->encoding = !empty($options['encoding']) ? $options['encoding'] : 'UTF-8';
    }
    $this->errors = array();
    $this->current = $this->doc;
    // ->documentElement;
    // Create a rules engine for tags.
    $this->rules = new TreeBuildingRules();
    $implicitNS = array();
    if (isset($this->options[self::OPT_IMPLICIT_NS])) {
        $implicitNS = $this->options[self::OPT_IMPLICIT_NS];
    }
    elseif (isset($this->options['implicitNamespaces'])) {
        $implicitNS = $this->options['implicitNamespaces'];
    }
    // Fill $nsStack with the defalut HTML5 namespaces, plus the "implicitNamespaces" array taken form $options
    array_unshift($this->nsStack, $implicitNS + array(
        '' => self::NAMESPACE_HTML,
    ) + $this->implicitNamespaces);
    if ($isFragment) {
        $this->insertMode = static::IM_IN_BODY;
        $this->frag = $this->doc
            ->createDocumentFragment();
        $this->current = $this->frag;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal