Skip to content

Commit

Permalink
fix: Add lang attribute to player el, so that css :lang() is correct (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-ben authored and brandonocasey committed Feb 15, 2017
1 parent 7ab52d1 commit 17143fd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 17143fd

Please sign in to comment.