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

Move player id generation #845

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ vjs.Player = vjs.Component.extend({
init: function(tag, options, ready){
this.tag = tag; // Store the original tag used to set options

// Make sure tag ID exists
tag.id = tag.id || 'vjs_video_' + vjs.guid++;

// Set Options
// The options argument overrides options set in the video tag
// which overrides globally set options.
Expand Down Expand Up @@ -205,9 +208,6 @@ vjs.Player.prototype.createEl = function(){
}
}

// Make sure tag ID exists
tag.id = tag.id || 'vjs_video_' + vjs.guid++;

// Give video tag ID and class to player div
// ID will now reference player box, not the video tag
el.id = tag.id;
Expand Down
15 changes: 15 additions & 0 deletions test/unit/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,18 @@ test('should use custom message when encountering an unsupported video type',

player.dispose();
});

test('should register players with generated ids', function(){
var fixture, video, player, id;
fixture = document.getElementById('qunit-fixture');

video = document.createElement('video');
video.className = 'vjs-default-skin video-js';
fixture.appendChild(video);

player = new vjs.Player(video);
id = player.el().id;

equal(player.el().id, player.id(), 'the player and element ids are equal');
ok(vjs.players[id], 'the generated id is registered');
});