src/Element/HTML/HTMLTableElement.php
/**
     * Returns the first tfoot element in the table, if one exists.  Otherwise,
     * it creates a new HTMLTableSectionElement and inserts it before the first
     * element that is not a caption or colgroup element in the table and
     * returns the newly created tfoot element.
     *
     * @see https://html.spec.whatwg.org/multipage/tables.html#dom-table-createthead
     */
Returns the first tfoot element in the table, if one exists.  Otherwise,
it creates a new HTMLTableSectionElement and inserts it before the first
element that is not a caption or colgroup element in the table and
returns the newly created tfoot element.


Returns the first tfoot element in the table if one exists . Otherwise it creates a new HTMLTableSectionElement and inserts it before the first element that is not a caption or colgroup element in the table and returns the newly created tfoot element .
public function createTHead(): HTMLTableSectionElement
    {
        $firstChild = $this->childNodes->first();
        $node = $firstChild;
        while ($node) {
            if ($node instanceof HTMLTableSectionElement && $node->localName === 'thead') {
                return $node;
            }
            $node = $node->nextSibling;
        }
        $thead = ElementFactory::create($this->nodeDocument, 'thead', Namespaces::HTML);
        $node = $firstChild;
        while ($node) {
            if (
                $node instanceof Element
                && !$node instanceof HTMLTableColElement
                && !$node instanceof HTMLTableCaptionElement
            ) {
                $this->preinsertNode($thead, $node);
                return $thead;
            }
            $node = $node->nextSibling;
        }
        $this->preinsertNode($thead);
        return $thead;
    }
public function createTHead ( ) : HTMLTableSectionElement { $ firstChild = $ this -> childNodes -> first ( ) ; $ node = $ firstChild ; while ( $ node ) { if ( $ node instanceof HTMLTableSectionElement && $ node -> localName === 'thead' ) { return $ node ; } $ node = $ node -> nextSibling ; } $ thead = ElementFactory :: create ( $ this -> nodeDocument , 'thead' , Namespaces :: HTML ) ; $ node = $ firstChild ; while ( $ node ) { if ( $ node instanceof Element && ! $ node instanceof HTMLTableColElement && ! $ node instanceof HTMLTableCaptionElement ) { $ this -> preinsertNode ( $ thead , $ node ) ; return $ thead ; } $ node = $ node -> nextSibling ; } $ this -> preinsertNode ( $ thead ) ; return $ thead ; }
Returns the first tfoot element in the table, if one exists.
Returns the first tfoot element in the table if one exists .