fix(v2): Allow the alt for the logo to be empty (#3352)

See
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img#Attributes

> Setting this attribute to an empty string (alt="") indicates that
> this image is not a key part of the content (it’s decoration or a
> tracking pixel), and that non-visual browsers may omit it from
> rendering.

Since the logo is indeed decorative and redundant with the actual
project name, an empty alt is fine.
This commit is contained in:
Vincent 2020-08-28 12:50:42 +02:00 committed by GitHub
parent c7fc781ce0
commit 56c04c7834
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -93,6 +93,22 @@ describe('themeConfig', () => {
}); });
}); });
test('should allow empty alt tags for the logo image in the header', () => {
const altTagConfig = {
navbar: {
logo: {
alt: '',
src: '/arbitrary-logo.png',
},
hideOnScroll: false,
},
};
expect(testValidateThemeConfig(altTagConfig)).toEqual({
colorMode: DEFAULT_COLOR_MODE_CONFIG,
...altTagConfig,
});
});
test('should accept valid prism config', () => { test('should accept valid prism config', () => {
const prismConfig = { const prismConfig = {
prism: { prism: {

View file

@ -181,7 +181,7 @@ const ThemeConfigSchema = Joi.object({
items: Joi.array().items(NavbarItemSchema), items: Joi.array().items(NavbarItemSchema),
title: Joi.string().allow('', null), title: Joi.string().allow('', null),
logo: Joi.object({ logo: Joi.object({
alt: Joi.string(), alt: Joi.string().allow(''),
src: Joi.string().required(), src: Joi.string().required(),
srcDark: Joi.string(), srcDark: Joi.string(),
href: Joi.string(), href: Joi.string(),