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

fix: Add lang attribute to player el, so that css :lang() is correct (#4046)

This commit is contained in:
mister-ben 2017-02-15 20:22:10 +00:00 committed by Brandon Casey
parent 7ab52d1a59
commit 17143fd9fe
2 changed files with 21 additions and 0 deletions

View File

@ -586,6 +586,10 @@ class Player extends Component {
Dom.prependTo(tag, el);
this.children_.unshift(tag);
// Set lang attr on player to ensure CSS :lang() in consistent with player
// if it's been set to something different to the doc
this.el_.setAttribute('lang', this.language_);
this.el_ = el;
return el;

View File

@ -1160,6 +1160,23 @@ QUnit.test('inherits language from parent element', function(assert) {
}
});
QUnit.test('sets lang attribute on player el', function(assert) {
const fixture = document.getElementById('qunit-fixture');
const oldLang = fixture.getAttribute('lang');
fixture.setAttribute('lang', 'x-attr-test');
const player = TestHelpers.makePlayer();
assert.equal(player.el().getAttribute('lang'), 'x-attr-test', 'player sets lang attribute on self');
player.dispose();
if (oldLang) {
fixture.setAttribute('lang', oldLang);
} else {
fixture.removeAttribute('lang');
}
});
QUnit.test('should return correct values for canPlayType', function(assert) {
const player = TestHelpers.makePlayer();