make sure that values like '0' are valid in select options
[php-utility-classes.git] / classes / document.php-class
index dbad7436beab02d0b313c7cbd9bf5fe9cb9960bc..c2f0fcfe0d9107d7baf897774dd79bda2d2f44f7 100755 (executable)
@@ -16,6 +16,10 @@ class ExtendedDocument extends DOMDocument {
   //     If a $doc is handed over (an ExtendedDocument or a derived class), load the content into that document.
   //     returns an associative array with the following elements: 'html', 'head', 'title', 'body'
   //
+  // public function loadHTML5($source) {
+  //   A version of loadHTML() - see DOMDocument documentation - that is made for loading HTML5 and not emitting warnings/errors for unknown elements.
+  //     returns true on success, false otherwise, just like loadHTML5.
+  //
   // public function appendElement($name, [$value])
   //   appends a DOMDocument::createElement() as a child of this document (see there for params)
   //     returns the new child
@@ -25,7 +29,7 @@ class ExtendedDocument extends DOMDocument {
   //   with an ExtendedDocument::createXMLFragment() of the given XML data inside
   //     returns the new child
   //
-  // public function appendLink($target, [$value])
+  // public function appendLink($target, [$value], [$title])
   //   appends an ExtendedDocument::createElementLink() as a child of this document (see there for params)
   //     returns the new child
   //
@@ -49,16 +53,44 @@ class ExtendedDocument extends DOMDocument {
   //   appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params)
   //     returns the new child
   //
+  // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params)
+  //     returns the new child
+  //
   // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
   //   appends an ExtendedDocument::createElementInputNumber() as a child of this document (see there for params)
   //     returns the new child
   //
+  // public function appendInputRange($name, $id, $min, $max, [$step], [$value])
+  //   appends an ExtendedDocument::createElementInputRange() as a child of this document (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputSearch($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputSearch() as a child of this document (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputUrl($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputUrl() as a child of this document (see there for params)
+  //     returns the new child
+  //
   // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
   //   appends an ExtendedDocument::createElementInputEmail() as a child of this document (see there for params)
   //     returns the new child
   //
-  // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
-  //   appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params)
+  // public function appendInputTel($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputTel() as a child of this document (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputDate($name, [$id], [$min], [$max], [$value])
+  //   appends an ExtendedDocument::createElementInputDate() as a child of this document (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputTime($name, [$id], [$min], [$max], [$value])
+  //   appends an ExtendedDocument::createElementInputTime() as a child of this document (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputColor($name, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputColor() as a child of this document (see there for params)
   //     returns the new child
   //
   // public function appendInputRadio($name, $id, $value, $checked)
@@ -85,7 +117,7 @@ class ExtendedDocument extends DOMDocument {
   //   appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params)
   //     returns the new child
   //
-  // public function appendElementSelect($name, [$id], [$options], [$default])
+  // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
   //   appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params)
   //     returns the new child
   //
@@ -97,10 +129,18 @@ class ExtendedDocument extends DOMDocument {
   //   appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params)
   //     returns the new child
   //
+  // public function appendElementDatalist([$id], [$options])
+  //   appends an ExtendedDocument::createElementDatalist() as a child of this document (see there for params)
+  //     returns the new child
+  //
   // public function appendText($text)
   //   appends a DOMDocument::createTextNode() as a child of this document (see there for params)
   //     returns the new child
   //
+  // public function appendLinebreak()
+  //   appends a <br> as a child of this document
+  //     returns the new child
+  //
   // public function appendEntity($name)
   //   appends a DOMDocument::createEntityReference() as a child of this document (see there for params)
   //     returns the new child
@@ -109,6 +149,11 @@ class ExtendedDocument extends DOMDocument {
   //   appends a DOMDocument::createComment() as a child of this document (see there for params)
   //     returns the new child
   //
+  // public function appendClonedElement($dom_element, [$deep])
+  //   appends a clone of the given DOMElement as a child of this document
+  //     the boolean $deep specifies if the children are cloned as well (defaults to TRUE)
+  //     returns the new child
+  //
   // public function appendHTMLMarkup($htmldata, [$parentNode])
   //   appends a representation of the HTML data as children of the given parent node, by default this document
   //     NO return value!
@@ -117,23 +162,26 @@ class ExtendedDocument extends DOMDocument {
   //   appends a representation of the XML data as children of the given parent node, by default this document
   //     NO return value!
   //
+  // public function appendStyleElement($styledata)
+  //   appends an ExtendedDocument::createElementStyle() as a child of this document (see there for params)
+  //     returns the new child
+  //
   // public function appendJSElement($jsdata)
   //   appends an ExtendedDocument::createElementJS() as a child of this document (see there for params)
-  //     NO return value!
+  //     returns the new child
   //
   // public function appendJSFile($jsURL, [$defer], [$async])
   //   appends an ExtendedDocument::createElementJSFile() as a child of this document (see there for params)
   //     returns the new child
   //
-  // public function createElementLink($target, [$value])
-  //   returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value
+  // public function createElementLink($target, [$value], [$title])
+  //   returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value as well as (optional) title attribute
   //
   // public function createElementImage($src, [$alt_text])
-  //   returns an ExtendedElement that is an HTML <img> with the given (src) and alt attributes (set to '' by default)
+  //   returns an ExtendedElement that is an HTML <img> with the given src and alt attributes (set to '' by default)
   //
   // public function createElementForm($action, $method, $name)
-  //   returns an ExtendedElement that is an HTML <div> that is a child of an HTML <form>
-  //   with the given action, method, and name
+  //   returns an ExtendedElement that is an HTML <form> with the given action, method, and name
   //
   // public function createElementInputHidden($name, $value)
   //   returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value
@@ -142,16 +190,44 @@ class ExtendedDocument extends DOMDocument {
   //   returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size,
   //   and optionally id and value
   //
+  // public function createElementInputPassword($name, $maxlength, $size, [$id], [$value])
+  //   returns an ExtendedElement that is an HTML <input> of type 'password' with the given name, maxlength, size,
+  //   and optionally id and value
+  //
   // public function createElementInputNumber($name, $maxlength, $size, [$id], [$value])
   //   returns an ExtendedElement that is an HTML <input> of type 'number' with the given name, maxlength, size,
   //   and optionally id and value
   //
+  // public function createElementInputRange($name, $id, $min, $max, [$step], [$value])
+  //   returns an ExtendedElement that is an HTML <input> of type 'range' with the given name, id, min, max,
+  //   and optionally step and value
+  //
+  // public function createElementInputUrl($name, $maxlength, $size, [$id], [$value])
+  //   returns an ExtendedElement that is an HTML <input> of type 'url' with the given name, maxlength, size,
+  //   and optionally id and value
+  //
+  // public function createElementInputSearch($name, $maxlength, $size, [$id], [$value])
+  //   returns an ExtendedElement that is an HTML <input> of type 'search' with the given name, maxlength, size,
+  //   and optionally id and value
+  //
   // public function createElementInputEmail($name, $maxlength, $size, [$id], [$value])
   //   returns an ExtendedElement that is an HTML <input> of type 'email' with the given name, maxlength, size,
   //   and optionally id and value
   //
-  // public function createElementInputPassword($name, $maxlength, $size, [$id], [$value])
-  //   returns an ExtendedElement that is an HTML <input> of type 'password' with the given name, maxlength, size,
+  // public function createElementInputTel($name, $maxlength, $size, [$id], [$value])
+  //   returns an ExtendedElement that is an HTML <input> of type 'tel' with the given name, maxlength, size,
+  //   and optionally id and value
+  //
+  // public function createElementInputDate($name, [$id], [$min], [$max], [$value])
+  //   returns an ExtendedElement that is an HTML <input> of type 'date' with the given name,
+  //   and optionally id, min, max, and value
+  //
+  // public function createElementInputTime($name, [$id], [$min], [$max], [$value])
+  //   returns an ExtendedElement that is an HTML <input> of type 'time' with the given name,
+  //   and optionally id, min, max, and value
+  //
+  // public function createElementInputColor($name, [$id], [$value])
+  //   returns an ExtendedElement that is an HTML <input> of type 'color' with the given name,
   //   and optionally id and value
   //
   // public function createElementInputRadio($name, $id, $value, $checked)
@@ -175,9 +251,9 @@ class ExtendedDocument extends DOMDocument {
   //   returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows,
   //   and optionally id and value
   //
-  // public function createElementSelect($name, [$id], [$options], [$default])
+  // public function createElementSelect($name, [$id], [$options], [$default], [$strictmatch])
   //   returns an ExtendedElement that is an HTML <select> with the given name, and optionally id,
-  //   array of options (key => description) and key of the by-default selected entry
+  //   array of options (key => description) and key of the by-default selected entry (matched including type when strictmatch is true)
   //
   // public function createElementOption($key, $desc, [$selected])
   //   returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content)
@@ -186,6 +262,12 @@ class ExtendedDocument extends DOMDocument {
   // public function createElementLabel($for_id, $value)
   //   returns an ExtendedElement that is an HTML <label> with the given 'for' and value
   //
+  // public function createElementDatalist([$id], [$options])
+  //   returns an ExtendedElement that is an HTML <datalist> with optionally the given id and array of options (key => description)
+  //
+  // public function createElementStyle($styledata)
+  //   returns an ExtendedElement that is an HTML <style> of CSS type with the style data inside
+  //
   // public function createElementJS($jsdata)
   //   returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside
   //
@@ -202,7 +284,7 @@ class ExtendedDocument extends DOMDocument {
 
   static function initHTML5($doc = null) {
     if (is_null($doc)) { $doc = new ExtendedDocument(); }
-    $doc->loadHTML('<!DOCTYPE html><html></html>'); // this seems to be the only way to get the DOCTYPE set properly.
+    $doc->loadHTML5('<?xml version="1.0" encoding="utf-8"?>'."\n".'<!DOCTYPE html>'."\n".'<html></html>'); // this seems to be the only way to get the DOCTYPE set properly.
 
     // Created basic HTML document structure.
     $root = $doc->getElementsByTagName('html')->item(0);
@@ -217,6 +299,35 @@ class ExtendedDocument extends DOMDocument {
                  'body' => $body);
   }
 
+  public function loadHTML5($source) {
+    // Do our own handling of DOMDocument error reporting so we can ignore "unknown tags" which are usually fine in HTML5.
+    libxml_use_internal_errors(true);
+    if (!preg_match('/^\s*<\?xml /', $source)) {
+      // Add an XML declaration to force DOMDocument into UTF-8 mode.
+      $source = '<?xml version="1.0" encoding="utf-8"?>'."\n".$source;
+    }
+    $result = $this->loadHTML($source);
+    // Set encoding directly a,d remove any processing node that isn't the first node
+    $this->encoding = 'utf-8';
+    foreach ($this->childNodes as $i => $child) {
+      if ($i && $child->nodeType == XML_PI_NODE) {
+        $this->removeChild($child);
+      }
+    }
+    // Handle DOMDocument loading errors, throw away warnings on unknown tags as HTML5 allows all kinds.
+    $errseverity = array(LIBXML_ERR_WARNING => 'Warning', LIBXML_ERR_ERROR => 'Error', LIBXML_ERR_FATAL => 'Fatal');
+    foreach (libxml_get_errors() as $error) {
+      // $error is a libXMLError, see https://www.php.net/manual/en/class.libxmlerror.php
+      // See http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors for error numbers
+      if ($error->code != 801) { // XML_HTML_UNKNOWN_TAG gets no output, should not exist for HTML5.
+        trigger_error($errseverity[$error->level].' loading HTML5: '.$error->message.' (code '.$error->code.'), line: '.$error->line, E_USER_WARNING);
+      }
+    }
+    libxml_clear_errors();
+    libxml_use_internal_errors(false);
+    return $result;
+  }
+
   public function appendElement($name, $value = '') {
     return $this->appendChild($this->createElement($name, $value));
   }
@@ -226,8 +337,8 @@ class ExtendedDocument extends DOMDocument {
     //$aelem->appendChild($this->createXMLFragment($xmldata));
     return $aelem;
   }
-  public function appendLink($target, $value = '') {
-    return $this->appendChild($this->createElementLink($target, $value));
+  public function appendLink($target, $value = '', $title = null) {
+    return $this->appendChild($this->createElementLink($target, $value, $title));
   }
   public function appendImage($src, $alt_text = '') {
     return $this->appendChild($this->createElementImage($src, $alt_text));
@@ -245,14 +356,35 @@ class ExtendedDocument extends DOMDocument {
   public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value));
   }
+  public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value));
+  }
   public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value));
   }
+  public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) {
+    return $this->appendChild($this->createElementInputRange($name, $id, $min, $max, $step, $value));
+  }
+  public function appendInputSearch($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->createElementInputSearch($name, $maxlength, $size, $id, $value));
+  }
+  public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->createElementInputUrl($name, $maxlength, $size, $id, $value));
+  }
   public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->createElementInputEmail($name, $maxlength, $size, $id, $value));
   }
-  public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
-    return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value));
+  public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->createElementInputTel($name, $maxlength, $size, $id, $value));
+  }
+  public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) {
+    return $this->appendChild($this->createElementInputDate($name, $id, $min, $max, $value));
+  }
+  public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) {
+    return $this->appendChild($this->createElementInputTime($name, $id, $min, $max, $value));
+  }
+  public function appendInputColor($name, $id = null, $value = null) {
+    return $this->appendChild($this->createElementInputColor($name, $id, $value));
   }
   public function appendInputRadio($name, $id, $value, $checked) {
     return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked));
@@ -272,8 +404,8 @@ class ExtendedDocument extends DOMDocument {
   public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
     return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value));
   }
-  public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
-    return $this->appendChild($this->createElementSelect($name, $id, $options, $default));
+  public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
+    return $this->appendChild($this->createElementSelect($name, $id, $options, $default, $strictmatch));
   }
   public function appendElementOption($key, $desc, $selected = false) {
     return $this->appendChild($this->createElementOption($key, $desc, $selected));
@@ -281,28 +413,40 @@ class ExtendedDocument extends DOMDocument {
   public function appendLabel($for_id, $value) {
     return $this->appendChild($this->createElementLabel($for_id, $value));
   }
+  public function appendElementDatalist($id = null, $options = array()) {
+    return $this->appendChild($this->createElementDatalist($id, $options));
+  }
   public function appendText($text) {
     return $this->appendChild($this->createTextNode($text));
   }
+  public function appendLinebreak() {
+    return $this->appendChild($this->createElement('br'));
+  }
   public function appendEntity($name) {
     return $this->appendChild($this->createEntityReference($name));
   }
   public function appendComment($comment_data) {
     return $this->appendChild($this->createComment($comment_data));
   }
+  public function appendClonedElement($dom_element, $deep = true) {
+    return $this->appendChild($dom_element->cloneNode($deep));
+  }
+  public function appendStyleElement($styledata) {
+    return $this->appendChild($this->createElementStyle($styledata));
+  }
   public function appendJSElement($jsdata) {
-    $this->appendChild($this->createElementJS($jsdata));
+    return $this->appendChild($this->createElementJS($jsdata));
   }
-  public function appendJSFile($jsdata, $defer = false, $async = false) {
-    return $this->appendChild($this->createElementJSFile($jsdata, $defer, $async));
+  public function appendJSFile($jsURL, $defer = false, $async = false) {
+    return $this->appendChild($this->createElementJSFile($jsURL, $defer, $async));
   }
 
   public function appendHTMLMarkup($htmldata, $parentNode = null) {
     if (is_null($parentNode)) { $parentNode =& $this; }
-    // Use loadHTML() to parse and turn the markup into proper HTML.
+    // Use loadHTML5() to parse and turn the markup into proper HTML.
     $tmpdoc = new ExtendedDocument;
     // The XML line is needed to tell the parser that we need UTF-8 parsing.
-    $tmpdoc->loadHTML('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html><html><body>'.$htmldata.'</body></html>');
+    $tmpdoc->loadHTML5('<?xml version="1.0" encoding="utf-8"?>'."\n".'<!DOCTYPE html>'."\n".'<html><body>'.$htmldata.'</body></html>');
     foreach ($tmpdoc->getElementsByTagName('body')->item(0)->childNodes as $child) {
       $parentNode->appendChild($this->importNode($child, true));
     }
@@ -323,13 +467,14 @@ class ExtendedDocument extends DOMDocument {
   public function createElement($name, $value = '') {
     // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that.
     $aelem = parent::createElement($name);
-    $aelem->appendText($value);
+    if (strlen($value ?? '')) { $aelem->appendText($value); }
     return $aelem;
   }
 
-  public function createElementLink($target, $value = '') {
+  public function createElementLink($target, $value = '', $title = null) {
     $link = $this->createElement('a', $value);
     $link->setAttribute('href', $target); // XXX: take care of & etc. in links
+    if (!is_null($title)) { $link->setAttribute('title', $title); }
     return $link;
   }
 
@@ -345,7 +490,7 @@ class ExtendedDocument extends DOMDocument {
     $formelem->setAttribute('action', $action);
     $formelem->setAttribute('method', $method);
     $formelem->setAttribute('name', $name);
-    $formelem->setAttribute('id', $id);
+    if (!is_null($id)) { $formelem->setAttribute('id', $id); }
     return $formelem;
   }
 
@@ -368,28 +513,6 @@ class ExtendedDocument extends DOMDocument {
     return $txfield;
   }
 
-  public function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) {
-    $txfield = $this->createElement('input');
-    $txfield->setAttribute('type', 'number');
-    if (!is_null($id)) { $txfield->setAttribute('id', $id); }
-    $txfield->setAttribute('name', $name);
-    $txfield->setAttribute('maxlength', $maxlength);
-    $txfield->setAttribute('size', $size);
-    if (!is_null($value)) { $txfield->setAttribute('value', $value); }
-    return $txfield;
-  }
-
-  public function createElementInputEmail($name, $maxlength, $size, $id = null, $value = null) {
-    $txfield = $this->createElement('input');
-    $txfield->setAttribute('type', 'email');
-    if (!is_null($id)) { $txfield->setAttribute('id', $id); }
-    $txfield->setAttribute('name', $name);
-    $txfield->setAttribute('maxlength', $maxlength);
-    $txfield->setAttribute('size', $size);
-    if (!is_null($value)) { $txfield->setAttribute('value', $value); }
-    return $txfield;
-  }
-
   public function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) {
     $pwfield = $this->createElement('input');
     $pwfield->setAttribute('type', 'password');
@@ -401,6 +524,104 @@ class ExtendedDocument extends DOMDocument {
     return $pwfield;
   }
 
+  public function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) {
+    $numfield = $this->createElement('input');
+    $numfield->setAttribute('type', 'number');
+    if (!is_null($id)) { $numfield->setAttribute('id', $id); }
+    $numfield->setAttribute('name', $name);
+    $numfield->setAttribute('maxlength', $maxlength);
+    $numfield->setAttribute('size', $size);
+    if (!is_null($value)) { $numfield->setAttribute('value', $value); }
+    return $numfield;
+  }
+
+  public function createElementInputRange($name, $id, $min, $max, $step = null, $value = null) {
+    $rgfield = $this->createElement('input');
+    $rgfield->setAttribute('type', 'range');
+    if (!is_null($id)) { $rgfield->setAttribute('id', $id); }
+    $rgfield->setAttribute('name', $name);
+    if (!is_null($min)) { $rgfield->setAttribute('min', $min); }
+    if (!is_null($max)) { $rgfield->setAttribute('max', $max); }
+    if (!is_null($step)) { $rgfield->setAttribute('step', $step); }
+    if (!is_null($value)) { $rgfield->setAttribute('value', $value); }
+    return $rgfield;
+  }
+
+  public function createElementInputSearch($name, $maxlength, $size, $id = null, $value = null) {
+    $urlfield = $this->createElement('input');
+    $urlfield->setAttribute('type', 'search');
+    if (!is_null($id)) { $urlfield->setAttribute('id', $id); }
+    $urlfield->setAttribute('name', $name);
+    $urlfield->setAttribute('maxlength', $maxlength);
+    $urlfield->setAttribute('size', $size);
+    if (!is_null($value)) { $urlfield->setAttribute('value', $value); }
+    return $urlfield;
+  }
+
+  public function createElementInputUrl($name, $maxlength, $size, $id = null, $value = null) {
+    $urlfield = $this->createElement('input');
+    $urlfield->setAttribute('type', 'url');
+    if (!is_null($id)) { $urlfield->setAttribute('id', $id); }
+    $urlfield->setAttribute('name', $name);
+    $urlfield->setAttribute('maxlength', $maxlength);
+    $urlfield->setAttribute('size', $size);
+    if (!is_null($value)) { $urlfield->setAttribute('value', $value); }
+    return $urlfield;
+  }
+
+  public function createElementInputEmail($name, $maxlength, $size, $id = null, $value = null) {
+    $mailfield = $this->createElement('input');
+    $mailfield->setAttribute('type', 'email');
+    if (!is_null($id)) { $mailfield->setAttribute('id', $id); }
+    $mailfield->setAttribute('name', $name);
+    $mailfield->setAttribute('maxlength', $maxlength);
+    $mailfield->setAttribute('size', $size);
+    if (!is_null($value)) { $mailfield->setAttribute('value', $value); }
+    return $mailfield;
+  }
+
+  public function createElementInputTel($name, $maxlength, $size, $id = null, $value = null) {
+    $telfield = $this->createElement('input');
+    $telfield->setAttribute('type', 'tel');
+    if (!is_null($id)) { $telfield->setAttribute('id', $id); }
+    $telfield->setAttribute('name', $name);
+    $telfield->setAttribute('maxlength', $maxlength);
+    $telfield->setAttribute('size', $size);
+    if (!is_null($value)) { $telfield->setAttribute('value', $value); }
+    return $telfield;
+  }
+
+  public function createElementInputDate($name, $id = null, $min = null, $max = null, $value = null) {
+    $dtfield = $this->createElement('input');
+    $dtfield->setAttribute('type', 'date');
+    if (!is_null($id)) { $dtfield->setAttribute('id', $id); }
+    $dtfield->setAttribute('name', $name);
+    if (!is_null($min)) { $dtfield->setAttribute('min', $min); }
+    if (!is_null($max)) { $dtfield->setAttribute('max', $max); }
+    if (!is_null($value)) { $dtfield->setAttribute('value', $value); }
+    return $dtfield;
+  }
+
+  public function createElementInputTime($name, $id = null, $min = null, $max = null, $value = null) {
+    $timefield = $this->createElement('input');
+    $timefield->setAttribute('type', 'time');
+    if (!is_null($id)) { $timefield->setAttribute('id', $id); }
+    $timefield->setAttribute('name', $name);
+    if (!is_null($min)) { $timefield->setAttribute('min', $min); }
+    if (!is_null($max)) { $timefield->setAttribute('max', $max); }
+    if (!is_null($value)) { $timefield->setAttribute('value', $value); }
+    return $timefield;
+  }
+
+  public function createElementInputColor($name, $id = null, $value = null) {
+    $colfield = $this->createElement('input');
+    $colfield->setAttribute('type', 'color');
+    if (!is_null($id)) { $colfield->setAttribute('id', $id); }
+    $colfield->setAttribute('name', $name);
+    if (!is_null($value)) { $colfield->setAttribute('value', $value); }
+    return $colfield;
+  }
+
   public function createElementInputRadio($name, $id, $value, $checked) {
     $radio = $this->createElement('input');
     $radio->setAttribute('type', 'radio');
@@ -454,20 +675,24 @@ class ExtendedDocument extends DOMDocument {
     return $txtarea;
   }
 
-  public function createElementSelect($name, $id = null, $options = array(), $default = null) {
+  public function createElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
     $select = $this->createElement('select');
     $select->setAttribute('name', $name);
     if (!is_null($id)) { $select->setAttribute('id', $id); }
     foreach ($options as $key => $desc) {
-      $select->appendElementOption($key, $desc, ($key == $default));
+      $select->appendElementOption($key, $desc, $strictmatch ? ($key === $default) : ($key == $default));
     }
     return $select;
   }
 
   public function createElementOption($key, $desc, $selected = false) {
     $option = $this->createElement('option', $desc);
-    $option->setAttribute('value', $key);
-    if ($selected) { $option->setAttribute('selected', ''); }
+    if (is_numeric($key) || is_string($key)) {
+      $option->setAttribute('value', $key);
+    }
+    if ($selected) {
+      $option->setAttribute('selected', '');
+    }
     return $option;
   }
 
@@ -477,6 +702,23 @@ class ExtendedDocument extends DOMDocument {
     return $label;
   }
 
+  public function createElementDatalist($id = null, $options = array()) {
+    $select = $this->createElement('datalist');
+    if (!is_null($id)) { $select->setAttribute('id', $id); }
+    foreach ($options as $key => $desc) {
+      $select->appendElementOption($key, $desc);
+    }
+    return $select;
+  }
+
+  public function createElementStyle($styledata) {
+    $style_elem = $this->createElement('style');
+    // Note: type can/should be left out for HTML5.
+    $style_elem->setAttribute('type', 'text/css');
+    $style_elem->appendChild($this->createCDATASection($styledata));
+    return $style_elem;
+  }
+
   public function createElementJS($jsdata) {
     $jselem = $this->createElement('script');
     // Note: type can/should be left out for HTML5.
@@ -513,7 +755,7 @@ class ExtendedElement extends DOMElement {
   //   with an ExtendedDocument::createXMLFragment() of the given XML data inside
   //     returns the new child
   //
-  // public function appendLink($target, [$value])
+  // public function appendLink($target, [$value], [$title])
   //   appends an ExtendedDocument::createElementLink() as a child of this element (see there for params)
   //     returns the new child
   //
@@ -537,18 +779,45 @@ class ExtendedElement extends DOMElement {
   //   appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params)
   //     returns the new child
   //
+  // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params)
+  //     returns the new child
+  //
   // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
   //   appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params)
   //     returns the new child
   //
+  // public function appendInputRange($name, $id, $min, $max, [$step], [$value])
+  //   appends an ExtendedDocument::createElementInputRange() as a child of this element (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputSearch($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputSearch() as a child of this element (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputUrl($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputUrl() as a child of this element (see there for params)
+  //     returns the new child
+  //
   // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
   //   appends an ExtendedDocument::createElementInputEmail() as a child of this element (see there for params)
   //     returns the new child
   //
-  // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
-  //   appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params)
+  // public function appendInputTel($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputTel() as a child of this element (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputDate($name, [$id], [$min], [$max], [$value])
+  //   appends an ExtendedDocument::createElementInputDate() as a child of this element (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputTime($name, [$id], [$min], [$max], [$value])
+  //   appends an ExtendedDocument::createElementInputTime() as a child of this element (see there for params)
   //     returns the new child
   //
+  // public function appendInputColor($name, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputColor() as a child of this element (see there for params)
+  //
   // public function appendInputRadio($name, $id, $value, $checked)
   //   appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params)
   //     returns the new child
@@ -573,7 +842,7 @@ class ExtendedElement extends DOMElement {
   //   appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params)
   //     returns the new child
   //
-  // public function appendElementSelect($name, [$id], [$options], [$default])
+  // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
   //   appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params)
   //     returns the new child
   //
@@ -585,10 +854,18 @@ class ExtendedElement extends DOMElement {
   //   appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params)
   //     returns the new child
   //
+  // public function appendElementDatalist([$id], [$options])
+  //   appends an ExtendedDocument::createElementDatalist() as a child of this element (see there for params)
+  //     returns the new child
+  //
   // public function appendText($text)
   //   appends a DOMDocument::createTextNode() as a child of this element (see there for params)
   //     returns the new child
   //
+  // public function appendLinebreak()
+  //   appends a <br> as a child of this element
+  //     returns the new child
+  //
   // public function appendEntity($name)
   //   appends a DOMDocument::createEntityReference() as a child of this element (see there for params)
   //     returns the new child
@@ -597,6 +874,11 @@ class ExtendedElement extends DOMElement {
   //   appends a DOMDocument::createComment() as a child of this element (see there for params)
   //     returns the new child
   //
+  // public function appendClonedElement($dom_element, [$deep])
+  //   appends a clone of the given DOMElement as a child of this element
+  //     the boolean $deep specifies if the children are cloned as well (defaults to TRUE)
+  //     returns the new child
+  //
   // public function appendHTMLMarkup($htmldata)
   //   appends a representation of the HTML data as children of this element
   //     NO return value!
@@ -605,13 +887,27 @@ class ExtendedElement extends DOMElement {
   //   appends a representation of the XML data as children of this element
   //     NO return value!
   //
+  // public function appendStyleElement($styledata)
+  //   appends an ExtendedDocument::createElementStyle() as a child of this element (see there for params)
+  //     returns the new child
+  //
   // public function appendJSElement($jsdata)
   //   appends an ExtendedDocument::createElementJS() as a child of this element (see there for params)
-  //     NO return value!
+  //     returns the new child
   //
   // public function appendJSFile($jsURL, [$defer], [$async])
   //   appends an ExtendedDocument::createElementJSFile() as a child of this element (see there for params)
   //     returns the new child
+  //
+  // public function setClass($classname)
+  //   sets the 'class' attribute of the element to the given classname value
+  //
+  // public function addClass($classname)
+  //   adds the given classname value to the space-separated list in the 'class' attribute
+  //     returns the value of the 'class' attribute
+  //
+  // public function setID($elem_id)
+  //   sets the 'id' attribute of the element to the given elem_id value
 
   public function appendElement($name, $value = '') {
     return $this->appendChild($this->ownerDocument->createElement($name, $value));
@@ -621,8 +917,8 @@ class ExtendedElement extends DOMElement {
     $aelem->appendXMLMarkup($xmldata);
     return $aelem;
   }
-  public function appendLink($target, $value = '') {
-    return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
+  public function appendLink($target, $value = '', $title = null) {
+    return $this->appendChild($this->ownerDocument->createElementLink($target, $value, $title));
   }
   public function appendImage($src, $alt_text = '') {
     return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
@@ -640,14 +936,35 @@ class ExtendedElement extends DOMElement {
   public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
   }
+  public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
+  }
   public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
   }
+  public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputRange($name, $id, $min, $max, $step, $value));
+  }
+  public function appendInputSearch($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputSearch($name, $maxlength, $size, $id, $value));
+  }
+  public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value));
+  }
   public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value));
   }
-  public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
-    return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
+  public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputTel($name, $maxlength, $size, $id, $value));
+  }
+  public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputDate($name, $id, $min, $max, $value));
+  }
+  public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputTime($name, $id, $min, $max, $value));
+  }
+  public function appendInputColor($name, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value));
   }
   public function appendInputRadio($name, $id, $value, $checked) {
     return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
@@ -667,8 +984,8 @@ class ExtendedElement extends DOMElement {
   public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
   }
-  public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
-    return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
+  public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
+    return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default, $strictmatch));
   }
   public function appendElementOption($key, $desc, $selected = false) {
     return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
@@ -676,8 +993,14 @@ class ExtendedElement extends DOMElement {
   public function appendLabel($for_id, $value) {
     return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
   }
+  public function appendElementDatalist($id = null, $options = array()) {
+    return $this->appendChild($this->ownerDocument->createElementDatalist($id, $options));
+  }
   public function appendText($text) {
-    return $this->appendChild($this->ownerDocument->createTextNode($text));
+    return $this->appendChild($this->ownerDocument->createTextNode($text ?? ''));
+  }
+  public function appendLinebreak() {
+    return $this->appendChild($this->ownerDocument->createElement('br'));
   }
   public function appendEntity($name) {
     return $this->appendChild($this->ownerDocument->createEntityReference($name));
@@ -685,17 +1008,36 @@ class ExtendedElement extends DOMElement {
   public function appendComment($comment_data) {
     return $this->appendChild($this->ownerDocument->createComment($comment_data));
   }
+  public function appendClonedElement($dom_element, $deep = true) {
+    return $this->appendChild($dom_element->cloneNode($deep));
+  }
   public function appendHTMLMarkup($htmldata) {
     $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
   }
   public function appendXMLMarkup($xmldata) {
     $this->ownerDocument->appendXMLMarkup($xmldata, $this);
   }
+  public function appendStyleElement($styledata) {
+    return $this->appendChild($this->ownerDocument->createElementStyle($styledata));
+  }
   public function appendJSElement($jsdata) {
-    $this->appendChild($this->ownerDocument->createElementJS($jsdata));
+    return $this->appendChild($this->ownerDocument->createElementJS($jsdata));
   }
-  public function appendJSFile($jsdata, $defer = false, $async = false) {
-    return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata, $defer, $async));
+  public function appendJSFile($jsURL, $defer = false, $async = false) {
+    return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async));
+  }
+  public function setClass($classname) {
+    $this->setAttribute('class', $classname);
+  }
+  public function addClass($classname) {
+    $classval = $this->getAttribute('class');
+    if (strlen($classval)) { $classval .= ' '; }
+    $classval .= $classname;
+    $this->setClass($classval);
+    return $classval;
+  }
+  public function setID($elem_id) {
+    $this->setAttribute('id', $elem_id);
   }
 }
 
@@ -712,7 +1054,7 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   //   with an ExtendedDocument::createXMLFragment() of the given XML data inside
   //     returns the new child
   //
-  // public function appendLink($target, [$value])
+  // public function appendLink($target, [$value], [$title])
   //   appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params)
   //     returns the new child
   //
@@ -736,18 +1078,45 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   //   appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params)
   //     returns the new child
   //
+  // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params)
+  //     returns the new child
+  //
   // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
   //   appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params)
   //     returns the new child
   //
+  // public function appendInputRange($name, $id, $min, $max, [$step], [$value])
+  //   appends an ExtendedDocument::createElementInputRange() as a child of this fragment (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputSearch($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputSearch() as a child of this fragment (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputUrl($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputUrl() as a child of this fragment (see there for params)
+  //     returns the new child
+  //
   // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
   //   appends an ExtendedDocument::createElementInputEmail() as a child of this fragment (see there for params)
   //     returns the new child
   //
-  // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
-  //   appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params)
+  // public function appendInputTel($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputTel() as a child of this fragment (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputDate($name, [$id], [$min], [$max], [$value])
+  //   appends an ExtendedDocument::createElementInputDate() as a child of this fragment (see there for params)
+  //     returns the new child
+  //
+  // public function appendInputTime($name, [$id], [$min], [$max], [$value])
+  //   appends an ExtendedDocument::createElementInputTime() as a child of this fragment (see there for params)
   //     returns the new child
   //
+  // public function appendInputColor($name, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputColor() as a child of this fragment (see there for params)
+  //
   // public function appendInputRadio($name, $id, $value, $checked)
   //   appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params)
   //     returns the new child
@@ -772,7 +1141,7 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   //   appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params)
   //     returns the new child
   //
-  // public function appendElementSelect($name, [$id], [$options], [$default])
+  // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
   //   appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params)
   //     returns the new child
   //
@@ -784,10 +1153,18 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   //   appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params)
   //     returns the new child
   //
+  // public function appendElementDatalist([$id], [$options])
+  //   appends an ExtendedDocument::createElementDatalist() as a child of this fragment (see there for params)
+  //     returns the new child
+  //
   // public function appendText($text)
   //   appends a DOMDocument::createTextNode() as a child of this fragment (see there for params)
   //     returns the new child
   //
+  // public function appendLinebreak()
+  //   appends a <br> as a child of this fragment
+  //     returns the new child
+  //
   // public function appendEntity($name)
   //   appends a DOMDocument::createEntityReference() as a child of this fragment (see there for params)
   //     returns the new child
@@ -796,6 +1173,11 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   //   appends a DOMDocument::createComment() as a child of this fragment (see there for params)
   //     returns the new child
   //
+  // public function appendClonedElement($dom_element, [$deep])
+  //   appends a clone of the given DOMElement as a child of this fragment
+  //     the boolean $deep specifies if the children are cloned as well (defaults to TRUE)
+  //     returns the new child
+  //
   // public function appendHTMLMarkup($htmldata)
   //   appends a representation of the HTML data as children of this fragment
   //     NO return value!
@@ -804,9 +1186,13 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   //   appends a representation of the XML data as children of this fragment
   //     NO return value!
   //
+  // public function appendStyleElement($styledata)
+  //   appends an ExtendedDocument::createElementStyle() as a child of this element (see there for params)
+  //     returns the new child
+  //
   // public function appendJSElement($jsdata)
   //   appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params)
-  //     NO return value!
+  //     returns the new child
   //
   // public function appendJSFile($jsURL, [$defer], [$async])
   //   appends an ExtendedDocument::createElementJSFile() as a child of this fragment (see there for params)
@@ -820,8 +1206,8 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
     $aelem->appendXMLMarkup($xmldata);
     return $aelem;
   }
-  public function appendLink($target, $value = '') {
-    return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
+  public function appendLink($target, $value = '', $title = null) {
+    return $this->appendChild($this->ownerDocument->createElementLink($target, $value, $title));
   }
   public function appendImage($src, $alt_text = '') {
     return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
@@ -839,14 +1225,35 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
   }
+  public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
+  }
   public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
   }
+  public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputRange($name, $id, $min, $max, $step, $value));
+  }
+  public function appendInputSearch($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputSearch($name, $maxlength, $size, $id, $value));
+  }
+  public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value));
+  }
   public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value));
   }
-  public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
-    return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
+  public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputTel($name, $maxlength, $size, $id, $value));
+  }
+  public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputDate($name, $id, $min, $max, $value));
+  }
+  public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputTime($name, $id, $min, $max, $value));
+  }
+  public function appendInputColor($name, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value));
   }
   public function appendInputRadio($name, $id, $value, $checked) {
     return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
@@ -866,8 +1273,8 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
   }
-  public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
-    return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
+  public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
+    return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default, $strictmatch));
   }
   public function appendElementOption($key, $desc, $selected = false) {
     return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
@@ -875,26 +1282,38 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   public function appendLabel($for_id, $value) {
     return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
   }
+  public function appendElementDatalist($id = null, $options = array()) {
+    return $this->appendChild($this->ownerDocument->createElementDatalist($id, $options));
+  }
   public function appendText($text) {
     return $this->appendChild($this->ownerDocument->createTextNode($text));
   }
+  public function appendLinebreak() {
+    return $this->appendChild($this->ownerDocument->createElement('br'));
+  }
   public function appendEntity($name) {
     return $this->appendChild($this->ownerDocument->createEntityReference($name));
   }
   public function appendComment($comment_data) {
     return $this->appendChild($this->ownerDocument->createComment($comment_data));
   }
+  public function appendClonedElement($dom_element, $deep = true) {
+    return $this->appendChild($dom_element->cloneNode($deep));
+  }
   public function appendHTMLMarkup($htmldata) {
     $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
   }
   public function appendXMLMarkup($xmldata) {
     $this->ownerDocument->appendXMLMarkup($xmldata, $this);
   }
+  public function appendStyleElement($styledata) {
+    return $this->appendChild($this->ownerDocument->createElementStyle($styledata));
+  }
   public function appendJSElement($jsdata) {
-    $this->appendChild($this->ownerDocument->createElementJS($jsdata));
+    return $this->appendChild($this->ownerDocument->createElementJS($jsdata));
   }
-  public function appendJSFile($jsdata, $defer = false, $async = false) {
-    return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata, $defer, $async));
+  public function appendJSFile($jsURL, $defer = false, $async = false) {
+    return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async));
   }
 }
 ?>