Merge "Improve docs for Title::getInternalURL/getCanonicalURL"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderImage.php
index ef11628..d10be12 100644 (file)
@@ -73,7 +73,7 @@ class ResourceLoaderImage {
                }
                // Remove 'deprecated' key
                if ( is_array( $this->descriptor ) ) {
-                       unset( $this->descriptor[ 'deprecated' ] );
+                       unset( $this->descriptor['deprecated'] );
                }
 
                // Ensure that all files have common extension.
@@ -295,9 +295,20 @@ class ResourceLoaderImage {
                $dom = new DOMDocument;
                $dom->loadXML( file_get_contents( $this->getPath( $context ) ) );
                $root = $dom->documentElement;
-               $wrapper = $dom->createElement( 'g' );
+               $titleNode = null;
+               $wrapper = $dom->createElementNS( 'http://www.w3.org/2000/svg', 'g' );
+               // Reattach all direct children of the `<svg>` root node to the `<g>` wrapper
                while ( $root->firstChild ) {
-                       $wrapper->appendChild( $root->firstChild );
+                       $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 );
                }
                $root->appendChild( $wrapper );
                $wrapper->setAttribute( 'fill', $variantConf['color'] );