From 1805fd3be51787b956573616154175fa4c66df08 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 15 Jan 2019 20:43:35 +0100 Subject: [PATCH] resourceloader: Avoid unnecessary xmlns attributes in ResourceLoaderImage We were creating the `` element without specifying a namespace, which caused the library to add `xmlns` attributes with the document's default SVG namespace to elements that we appended underneath it. (At least, that's what I think was happening.) Specify the SVG namespace when creating it to avoid the mess and reduce resulting file size. Change-Id: Ida27494aeae9dece16f878c16cf9aa582e6deac3 --- includes/resourceloader/ResourceLoaderImage.php | 2 +- tests/phpunit/data/resourceloader/def_variantize.svg | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index b15efae809..8cd5b19fd4 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -296,7 +296,7 @@ class ResourceLoaderImage { $dom->loadXML( file_get_contents( $this->getPath( $context ) ) ); $root = $dom->documentElement; $titleNode = null; - $wrapper = $dom->createElement( 'g' ); + $wrapper = $dom->createElementNS( 'http://www.w3.org/2000/svg', 'g' ); // Reattach all direct children of the `` root node to the `` wrapper while ( $root->firstChild ) { $node = $root->firstChild; diff --git a/tests/phpunit/data/resourceloader/def_variantize.svg b/tests/phpunit/data/resourceloader/def_variantize.svg index 009d805bc0..641bb786a8 100644 --- a/tests/phpunit/data/resourceloader/def_variantize.svg +++ b/tests/phpunit/data/resourceloader/def_variantize.svg @@ -1,7 +1,7 @@ -remove +remove - + -- 2.20.1