src/Document.php
/**
     * Creates an Element with the specified tag name.
     *
     * @see https://dom.spec.whatwg.org/#dom-document-createelement
     *
     * @throws \Rowbot\DOM\Exception\InvalidCharacterError
     */
Creates an Element with the specified tag name.


Creates an Element with the specified tag name .
public function createElement(string $localName): Element
    {
        if (!preg_match(Namespaces::NAME_PRODUCTION, $localName)) {
            throw new InvalidCharacterError();
        }
        if ($this instanceof HTMLDocument) {
            $localName = Utils::toASCIILowercase($localName);
        }
        switch ($this->contentType) {
            case 'text/html':
            case 'application/xhtml+xml':
                $namespace = Namespaces::HTML;
                break;
            default:
                $namespace = null;
        }
        $element = ElementFactory::create($this, $localName, $namespace, null);
        return $element;
    }
public function createElement ( string $ localName ) : Element { if ( ! preg_match ( Namespaces :: NAME_PRODUCTION , $ localName ) ) { throw new InvalidCharacterError ( ) ; } if ( $ this instanceof HTMLDocument ) { $ localName = Utils :: toASCIILowercase ( $ localName ) ; } switch ( $ this -> contentType ) { case 'text/html' : case 'application/xhtml+xml' : $ namespace = Namespaces :: HTML ; break ; default : $ namespace = null ; } $ element = ElementFactory :: create ( $ this , $ localName , $ namespace , null ) ; return $ element ; }
Creates an Element with the specified tag name.
Creates an Element with the specified tag name .
// If localName does not match the Name production, then throw an // InvalidCharacterError. // If the context object is an HTML document, let localName be converted // to ASCII lowercase. // Let namespace be the HTML namespace, if the context object’s content // type is "text/html" or "application/xhtml+xml", and null otherwise.