Skip to content

Commit b855bfb

Browse files
mister-bengkatsev
authored andcommitted
feat: Add a version class to the player (#4335)
Adds `vjs-v5` class so you can target that version of Video.js.
1 parent 3fe22e9 commit b855bfb

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/js/player.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ class Player extends Component {
413413
// Make player easily findable by ID
414414
Player.players[this.id_] = this;
415415

416+
// Add a major version class to aid css in plugins
417+
const majorVersion = require('../../package.json').version.split('.')[0];
418+
419+
this.addClass(`vjs-v${majorVersion}`);
420+
416421
// When the player is first initialized, trigger activity so components
417422
// like the control bar show themselves if needed
418423
this.userActive(true);

test/unit/player.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,3 +1387,12 @@ QUnit.test('should not allow to register custom player when any player has been
13871387
// reset the Player to the original value;
13881388
videojs.registerComponent('Player', Player);
13891389
});
1390+
1391+
QUnit.test('should add a class with major version', function(assert) {
1392+
const majorVersion = require('../../package.json').version.split('.')[0];
1393+
const player = TestHelpers.makePlayer();
1394+
1395+
assert.ok(player.hasClass('vjs-v' + majorVersion), 'the version class should be added to the player');
1396+
1397+
player.dispose();
1398+
});

0 commit comments

Comments
 (0)