mirror of
https://github.com/videojs/video.js.git
synced 2025-01-27 11:22:06 +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(){
|
vjs.Player.prototype.createEl = function(){
|
||||||
var el = this.el_ = vjs.Component.prototype.createEl.call(this, 'div');
|
var
|
||||||
var tag = this.tag;
|
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
|
// Remove width/height attrs from tag so CSS can make it 100% width/height
|
||||||
tag.removeAttribute('width');
|
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
|
// ID will now reference player box, not the video tag
|
||||||
el.id = tag.id;
|
attrs = vjs.getAttributeValues(tag);
|
||||||
el.className = tag.className;
|
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
|
// Update tag id/class for use as HTML5 playback tech
|
||||||
// Might think we should do this after embedding in container so .vjs-tech class
|
// 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();
|
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