Commit 7063ac9f authored by dpapad's avatar dpapad Committed by Commit Bot

Stop stripping viewBox when performing SVG optimizations with svgo.

Fixed: 1019798
Change-Id: Idfd2502fa32dfa44ad19b105f5d4bc9a54eb15e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1891147Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710979}
parent b76eeb9f
......@@ -19,7 +19,11 @@ def Run(os_path=None, args=None):
finally:
sys.path = old_sys_path
return node.RunNode([node_modules.PathToSvgo()] + args)
# Removing viewBox is not always safe, since it assumes that width/height are
# not overriden in all usages of an SVG file. Feel free to remove viewBox
# manually from a certain SVG if you have audited all its usages.
default_args = ['--disable=removeViewBox'];
return node.RunNode([node_modules.PathToSvgo()] + default_args + args)
if __name__ == '__main__':
......
......@@ -16,7 +16,7 @@ sys.path.append(os.path.join(_HERE_PATH, '..', '..'))
from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi, MockFile
_OPTIMIZED_SVG = '''
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="#757575"><path d="M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#757575"><path d="M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"/></svg>
'''.strip()
_UNOPTIMIZED_SVG = '''
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment