Bartosz Dziewoński has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/336424 )
Change subject: colorize-svg: Colorize using a method compatible with rsvg ...................................................................... colorize-svg: Colorize using a method compatible with rsvg We've been using this approach in MediaWiki for a while already. This will allow the icons to be correctly rendered when uploaded to Wikimedia Commons, e.g. for use in guides and documentation. Bug: T154572 Change-Id: If223b90cfe2f0bba8b4e5f4d55984ba15d759c76 --- M build/tasks/colorize-svg.js 1 file changed, 8 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/24/336424/1 diff --git a/build/tasks/colorize-svg.js b/build/tasks/colorize-svg.js index 952af2b..be387de 100644 --- a/build/tasks/colorize-svg.js +++ b/build/tasks/colorize-svg.js @@ -254,10 +254,10 @@ declarations = getDeclarations( variantizeFileName( file[ direction ], variantName ) ); rules[ direction ].push( selector + ' {\n\t' + declarations + '\n}' ); - // TODO: Do this in a safer and more clever way - variantSvg = originalSvg[ direction ].replace( - /<svg[^>]*>/, '$&<style>* { fill: ' + variant.getColor() + ' }</style>' - ); + // TODO: Do this using proper DOM manipulation, not regexp magic + variantSvg = originalSvg[ direction ] + .replace( /<svg[^>]*>/, '$&<g fill="' + variant.getColor() + '">' ) + .replace( /<\/svg>/, '</g>$&' ); if ( originalSvg[ direction ] === variantSvg ) { uncolorizableImages.push( file[ direction ] ); @@ -279,9 +279,10 @@ ' {\n\t' + declarations + '\n}' ); - variantSvg = originalSvg[ 'lang-' + lang ].replace( - /<svg[^>]*>/, '$&<style>* { fill: ' + variant.getColor() + ' }</style>' - ); + // TODO: Do this using proper DOM manipulation, not regexp magic + variantSvg = originalSvg[ 'lang-' + lang ] + .replace( /<svg[^>]*>/, '$&<g fill="' + variant.getColor() + '">' ) + .replace( /<\/svg>/, '</g>$&' ); if ( originalSvg[ 'lang-' + lang ] === variantSvg ) { uncolorizableImages.push( moreLangs[ lang ] ); -- To view, visit https://gerrit.wikimedia.org/r/336424 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If223b90cfe2f0bba8b4e5f4d55984ba15d759c76 Gerrit-PatchSet: 1 Gerrit-Project: oojs/ui Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits