mirror of
https://github.com/videojs/video.js.git
synced 2025-01-25 11:13:52 +02:00
Merge branch 'data-attributes' of github.com:gkatsev/video.js into gkatsev-data-attributes
This commit is contained in:
commit
34ad720626
@ -159,8 +159,10 @@ vjs.Player.prototype.getTagSettings = function(tag){
|
||||
};
|
||||
|
||||
vjs.Player.prototype.createEl = function(){
|
||||
var el = this.el_ = vjs.Component.prototype.createEl.call(this, 'div');
|
||||
var tag = this.tag;
|
||||
var
|
||||
el = this.el_ = vjs.Component.prototype.createEl.call(this, 'div'),
|
||||
tag = this.tag,
|
||||
attrs;
|
||||
|
||||
// Remove width/height attrs from tag so CSS can make it 100% width/height
|
||||
tag.removeAttribute('width');
|
||||
@ -189,10 +191,14 @@ vjs.Player.prototype.createEl = function(){
|
||||
}
|
||||
}
|
||||
|
||||
// Give video tag ID and class to player div
|
||||
// Copy over all the attributes from the tag, including ID and class
|
||||
// ID will now reference player box, not the video tag
|
||||
el.id = tag.id;
|
||||
el.className = tag.className;
|
||||
attrs = vjs.getAttributeValues(tag);
|
||||
vjs.obj.each(attrs, function(attr) {
|
||||
if (Object.prototype.hasOwnProperty.call(attrs, attr)) {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
});
|
||||
|
||||
// Update tag id/class for use as HTML5 playback tech
|
||||
// Might think we should do this after embedding in container so .vjs-tech class
|
||||
|
@ -482,3 +482,15 @@ test('player should handle different error types', function(){
|
||||
vjs.log.error.restore();
|
||||
});
|
||||
|
||||
test('Data attributes on the video element should persist in the new wrapper element', function() {
|
||||
var dataId, tag, player;
|
||||
|
||||
dataId = 123;
|
||||
|
||||
tag = PlayerTest.makeTag();
|
||||
tag.setAttribute('data-id', dataId);
|
||||
|
||||
player = PlayerTest.makePlayer({}, tag);
|
||||
|
||||
equal(player.el().getAttribute('data-id'), dataId, 'data-id should be available on the new player element after creation');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user