You are here

public function TreeBuildingRules::evaluate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/masterminds/html5/src/HTML5/Parser/TreeBuildingRules.php \Masterminds\HTML5\Parser\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 61

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