1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-25 02:42:10 +02:00

fix: Set alt attr on poster img (#8043)

* fix: Set alt attr on poster img

* use null alt instead

* remove debug text
This commit is contained in:
mister-ben 2023-01-24 09:59:27 +01:00 committed by GitHub
parent e21d295d77
commit 3accbc7c73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions

View File

@ -46,15 +46,21 @@ class PosterImage extends ClickableComponent {
* The element that gets created. * The element that gets created.
*/ */
createEl() { createEl() {
const el = Dom.createEl('picture', { const el = Dom.createEl(
'picture', {
className: 'vjs-poster', className: 'vjs-poster',
// Don't want poster to be tabbable. // Don't want poster to be tabbable.
tabIndex: -1 tabIndex: -1
}, {}, Dom.createEl('img', { },
{},
Dom.createEl('img', {
loading: 'lazy', loading: 'lazy',
crossOrigin: this.crossOrigin() crossOrigin: this.crossOrigin()
})); }, {
alt: ''
})
);
return el; return el;
} }

View File

@ -42,6 +42,12 @@ QUnit.test('should mirror crossOrigin', function(assert) {
}); });
QUnit.test('should populate an alt attribute', function(assert) {
const posterImage = new PosterImage(this.mockPlayer);
assert.ok(posterImage.$('img').hasAttribute('alt'), 'img has alt atttribute');
});
QUnit.test('should remove itself from the document flow when there is no poster', function(assert) { QUnit.test('should remove itself from the document flow when there is no poster', function(assert) {
const posterImage = new PosterImage(this.mockPlayer); const posterImage = new PosterImage(this.mockPlayer);