Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a version class to the player #4320

Merged
merged 1 commit into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});