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

Breadcrumb

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

function TreeBuildingRules::evaluate

Evaluate the rule for the current tag name.

This may modify the existing DOM.

Return value

\DOMElement The new Current DOM element.

File

vendor/masterminds/html5/src/HTML5/Parser/TreeBuildingRules.php, line 50

Class

TreeBuildingRules
Handles special-case rules for the DOM tree builder.

Namespace

Masterminds\HTML5\Parser

Code

public function evaluate($new, $current) {
    switch ($new->tagName) {
        case 'li':
            return $this->handleLI($new, $current);
        case 'dt':
        case 'dd':
            return $this->handleDT($new, $current);
        case 'rt':
        case 'rp':
            return $this->handleRT($new, $current);
        case 'optgroup':
            return $this->closeIfCurrentMatches($new, $current, array(
                'optgroup',
            ));
        case 'option':
            return $this->closeIfCurrentMatches($new, $current, array(
                'option',
            ));
        case 'tr':
            return $this->closeIfCurrentMatches($new, $current, array(
                'tr',
            ));
        case 'td':
        case 'th':
            return $this->closeIfCurrentMatches($new, $current, array(
                'th',
                'td',
            ));
        case 'tbody':
        case 'thead':
        case 'tfoot':
        case 'table':
            // Spec isn't explicit about this, but it's necessary.
            return $this->closeIfCurrentMatches($new, $current, array(
                'thead',
                'tfoot',
                'tbody',
            ));
    }
    return $current;
}

API Navigation

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