fix(utils): make SVGO not remove title (#6684)

* chore(utils): add `removeTitle: false` to svg loader

By default, SVGR removes the `<title>` tag from SVG inputs.
This hinders a11y since "the `<title>` element provides an
accessible, short-text description of any SVG container
element or graphics element".

Modern browsers also show tooltips on hover for inline
SVG with the `<title>` tag.

See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title

* fix test
This commit is contained in:
Erick Zhao 2022-02-15 01:14:54 -08:00 committed by GitHub
parent 94532dfd26
commit 0c6165b161
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -8,7 +8,7 @@
import {getFileLoaderUtils} from '../webpackUtils';
describe('getFileLoaderUtils()', () => {
test('plugin svgo/removeViewBox should be disabled', () => {
test('plugin svgo/removeViewBox and removeTitle should be disabled', () => {
const {oneOf} = getFileLoaderUtils().rules.svg();
expect(oneOf[0].use).toContainEqual(
expect.objectContaining({
@ -20,6 +20,7 @@ describe('getFileLoaderUtils()', () => {
name: 'preset-default',
params: {
overrides: {
removeTitle: false,
removeViewBox: false,
},
},

View file

@ -112,6 +112,7 @@ export function getFileLoaderUtils(): FileLoaderUtils {
name: 'preset-default',
params: {
overrides: {
removeTitle: false,
removeViewBox: false,
},
},