Fix rerendering of React-based icons in HiDPI mode

With the variable in the outer scope, "@2x" keeps getting added to the
URL.
This commit is contained in:
Dan Stillman 2020-12-31 13:50:51 -05:00
parent 4db61b8dc7
commit a1267bc68e

View file

@ -26,12 +26,13 @@ function i(name, svgOrSrc, hasDPI=true) {
const { className } = this.props
if (typeof svgOrSrc == 'string') {
let finalSrc = svgOrSrc;
if (hasDPI && window.devicePixelRatio >= 1.25) {
let parts = svgOrSrc.split('.');
parts[parts.length-2] = parts[parts.length-2] + '@2x';
svgOrSrc = parts.join('.')
finalSrc = parts.join('.')
}
return <Icon className={className} name={name.toLowerCase()}><img src={svgOrSrc}/></Icon>
return <Icon className={className} name={name.toLowerCase()}><img src={finalSrc}/></Icon>
}
return (