src/Element/HTML/HTMLTableElement.php
/**
     * Returns the first caption element in the table, if one exists.
     * Otherwise, it creates a new HTMLTableCaptionElement and inserts it before
     * the table's first child and returns the newly created caption element.
     *
     * @see https://html.spec.whatwg.org/multipage/tables.html#dom-table-createcaption
     */
Returns the first caption element in the table, if one exists.
Otherwise, it creates a new HTMLTableCaptionElement and inserts it before
the table's first child and returns the newly created caption element.


Returns the first caption element in the table if one exists . Otherwise it creates a new HTMLTableCaptionElement and inserts it before the table ' s first child and returns the newly created caption element .
public function createCaption(): HTMLTableCaptionElement
    {
        $firstChild = $this->childNodes->first();
        $node = $firstChild;
        while ($node) {
            if ($node instanceof HTMLTableCaptionElement) {
                return $node;
            }
            $node = $node->nextSibling;
        }
        $caption = ElementFactory::create($this->nodeDocument, 'caption', Namespaces::HTML);
        $this->insertNode($caption, $firstChild);
        return $caption;
    }
public function createCaption ( ) : HTMLTableCaptionElement { $ firstChild = $ this -> childNodes -> first ( ) ; $ node = $ firstChild ; while ( $ node ) { if ( $ node instanceof HTMLTableCaptionElement ) { return $ node ; } $ node = $ node -> nextSibling ; } $ caption = ElementFactory :: create ( $ this -> nodeDocument , 'caption' , Namespaces :: HTML ) ; $ this -> insertNode ( $ caption , $ firstChild ) ; return $ caption ; }
Returns the first caption element in the table, if one exists.
Returns the first caption element in the table if one exists .