Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / masterminds / html5 / src / HTML5 / Parser / DOMTreeBuilder.php
index b26860da9c1bb1f3e1c851c6e2a5db95377f389b..865c5f0c7c334740aa15d4a1c6dc947f3981dcd1 100644 (file)
@@ -433,10 +433,16 @@ class DOMTreeBuilder implements EventHandler
         else {
             $this->current->appendChild($ele);
 
-            // XXX: Need to handle self-closing tags and unary tags.
             if (! Elements::isA($name, Elements::VOID_TAG)) {
                 $this->current = $ele;
             }
+
+            // Self-closing tags should only be respected on foreign elements
+            // (and are implied on void elements)
+            // See: https://www.w3.org/TR/html5/syntax.html#start-tags
+            if (Elements::isHtml5Element($name)) {
+                $selfClosing = false;
+            }
         }
 
         // This is sort of a last-ditch attempt to correct for cases where no head/body
@@ -453,6 +459,11 @@ class DOMTreeBuilder implements EventHandler
                 array_shift($this->nsStack);
             }
         }
+
+        if ($selfClosing) {
+            $this->endTag($name);
+        }
+
         // Return the element mask, which the tokenizer can then use to set
         // various processing rules.
         return Elements::element($name);