Skip to content

Commit

Permalink
feat: Add a version class to the player (#4320)
Browse files Browse the repository at this point in the history
Adds `vjs-v6` class so you can target that version of Video.js.
  • Loading branch information
mister-ben authored and gkatsev committed May 11, 2017
1 parent 0a19cf0 commit ae423df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,11 @@ class Player extends Component {
// Make player easily findable by ID
Player.players[this.id_] = this;

// Add a major version class to aid css in plugins
const majorVersion = require('../../package.json').version.split('.')[0];

this.addClass(`vjs-v${majorVersion}`);

// When the player is first initialized, trigger activity so components
// like the control bar show themselves if needed
this.userActive(true);
Expand Down
9 changes: 9 additions & 0 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1617,3 +1617,12 @@ QUnit.test('options: plugins', function(assert) {
player.dispose();
Plugin.deregisterPlugin('foo');
});

QUnit.test('should add a class with major version', function(assert) {
const majorVersion = require('../../package.json').version.split('.')[0];
const player = TestHelpers.makePlayer();

assert.ok(player.hasClass('vjs-v' + majorVersion), 'the version class should be added to the player');

player.dispose();
});

0 comments on commit ae423df

Please sign in to comment.