Skip to content

Commit

Permalink
fix: Set alt attr on poster img (#8043)
Browse files Browse the repository at this point in the history
* fix: Set alt attr on poster img

* use null alt instead

* remove debug text
  • Loading branch information
mister-ben authored Jan 24, 2023
1 parent e21d295 commit 3accbc7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/js/poster-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,21 @@ class PosterImage extends ClickableComponent {
* The element that gets created.
*/
createEl() {
const el = Dom.createEl('picture', {
className: 'vjs-poster',

// Don't want poster to be tabbable.
tabIndex: -1
}, {}, Dom.createEl('img', {
loading: 'lazy',
crossOrigin: this.crossOrigin()
}));
const el = Dom.createEl(
'picture', {
className: 'vjs-poster',

// Don't want poster to be tabbable.
tabIndex: -1
},
{},
Dom.createEl('img', {
loading: 'lazy',
crossOrigin: this.crossOrigin()
}, {
alt: ''
})
);

return el;
}
Expand Down
6 changes: 6 additions & 0 deletions test/unit/poster.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
const posterImage = new PosterImage(this.mockPlayer);

Expand Down

0 comments on commit 3accbc7

Please sign in to comment.