|
|
@ -160,15 +160,9 @@ abstract class Serializer { |
|
|
|
# If the node is a template element, then let the node instead |
|
|
|
# be the template element's template contents |
|
|
|
# (a DocumentFragment node). |
|
|
|
if ( |
|
|
|
$htmlElement |
|
|
|
&& $n->tagName === "template" |
|
|
|
&& property_exists($n, "content") |
|
|
|
&& $n->content instanceof \DOMDocumentFragment |
|
|
|
) { |
|
|
|
// NOTE: Treat template content as any other document |
|
|
|
// fragment and just invoke the inner serializer |
|
|
|
$s .= self::serializeInner($n->content, $config)."</$tagName>"; |
|
|
|
if ($htmlElement && $n->tagName === "template" && ((property_exists($node, "content") && $node->content instanceof \DOMDocumentFragment) || $node->ownerDocument instanceof \MensBeam\HTML\DOM\InnerNode\Document)) { |
|
|
|
// NOTE: The inner serializer will determine what to do with template content |
|
|
|
$s .= self::serializeInner($n, $config)."</$tagName>"; |
|
|
|
} elseif ($n->hasChildNodes()) { |
|
|
|
// If the element has children, store its tag name and |
|
|
|
// continue the loop with its first child; its end |
|
|
@ -269,10 +263,18 @@ abstract class Serializer { |
|
|
|
# If the node is a template element, then let the node instead |
|
|
|
# be the template element's template contents |
|
|
|
# (a DocumentFragment node). |
|
|
|
elseif ($node->tagName === "template" && property_exists($node, "content") && $node->content instanceof \DOMDocumentFragment) { |
|
|
|
elseif ($node->tagName === "template") { |
|
|
|
// NOTE: template elements won't necessarily have a content |
|
|
|
// property because PHP's DOM does not support this natively |
|
|
|
$node = $node->content; |
|
|
|
if (property_exists($node, "content") && $node->content instanceof \DOMDocumentFragment) { |
|
|
|
$node = $node->content; |
|
|
|
} |
|
|
|
// Special case for MensBeam's DOM which wraps DOM classes. While traversing |
|
|
|
// the DOM occurs within its inner DOM, template contents are entirely in the |
|
|
|
// userland wrapper class, so that must be accounted for. |
|
|
|
elseif ($node->ownerDocument instanceof \MensBeam\HTML\DOM\InnerNode\Document) { |
|
|
|
$node = $node->ownerDocument->getInnerNode($node->ownerDocument->getWrapperNode($node)->content); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ($node instanceof \DOMElement || $node instanceof \DOMDocument || $node instanceof \DOMDocumentFragment) { |
|
|
|