Ensure dom fragment is never empty in terms of child nodes
authorAlexander Ebert <ebert@woltlab.com>
Sun, 10 Jul 2016 22:09:46 +0000 (00:09 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 10 Jul 2016 22:10:03 +0000 (00:10 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php

index 8b8251d838482f55fed3cbe95e0c56dd145e1998..9311e2c91f4fdcadc362711d1c21a8b92df189ad 100644 (file)
@@ -74,7 +74,10 @@ class HtmlInputNodeWoltlabMetacode extends AbstractHtmlInputNode {
                        
                        /** @var IMetacodeConverter $converter */
                        if ($converter->validateAttributes($attributes)) {
-                               $newElement = $converter->convert(DOMUtil::childNodesToFragment($element), $attributes);
+                               $fragment = DOMUtil::childNodesToFragment($element);
+                               if (!$fragment->hasChildNodes()) $fragment->appendChild($fragment->ownerDocument->createTextNode(''));
+                               
+                               $newElement = $converter->convert($fragment, $attributes);
                                if (!($newElement instanceof \DOMElement)) {
                                        throw new \UnexpectedValueException("Expected a valid DOMElement as return value.");
                                }