+ $node = $root->firstChild;
+ if ( !$titleNode && $node->nodeType === XML_ELEMENT_NODE && $node->tagName === 'title' ) {
+ // Remember the first encountered `<title>` node
+ $titleNode = $node;
+ }
+ $wrapper->appendChild( $node );
+ }
+ if ( $titleNode ) {
+ // Reattach the `<title>` node to the `<svg>` root node rather than the `<g>` wrapper
+ $root->appendChild( $titleNode );