mirror of
https://github.com/videojs/video.js.git
synced 2025-03-03 15:12:49 +02:00
vjs.Component.dimension accepts 'auto' as value
test case for vjs.Component.dimension with 'auto'
This commit is contained in:
parent
696097ca38
commit
a3b9b50e8b
@ -618,6 +618,8 @@ vjs.Component.prototype.dimension = function(widthOrHeight, num, skipListeners){
|
||||
// Check if using css width/height (% or px) and adjust
|
||||
if ((''+num).indexOf('%') !== -1 || (''+num).indexOf('px') !== -1) {
|
||||
this.el_.style[widthOrHeight] = num;
|
||||
} else if (num === 'auto') {
|
||||
this.el_.style[widthOrHeight] = '';
|
||||
} else {
|
||||
this.el_.style[widthOrHeight] = num+'px';
|
||||
}
|
||||
|
@ -171,13 +171,9 @@ vjs.Player.prototype.createEl = function(){
|
||||
|
||||
// Make box use width/height of tag, or rely on default implementation
|
||||
// Enforce with CSS since width/height attrs don't work on divs
|
||||
if (this.options_['width'] !== 'auto') {
|
||||
this.width(this.options_['width'], true); // (true) Skip resize listener on load
|
||||
}
|
||||
if (this.options_['height'] !== 'auto') {
|
||||
this.height(this.options_['height'], true);
|
||||
}
|
||||
|
||||
this.width(this.options_['width'], true); // (true) Skip resize listener on load
|
||||
this.height(this.options_['height'], true);
|
||||
|
||||
// Wrap video tag in div (el/box) container
|
||||
if (tag.parentNode) {
|
||||
tag.parentNode.insertBefore(el, tag);
|
||||
|
@ -184,4 +184,9 @@ test('should change the width and height of a component', function(){
|
||||
|
||||
comp.width(321);
|
||||
ok(comp.width() === 321, 'integer values working');
|
||||
|
||||
comp.width('auto');
|
||||
comp.height('auto');
|
||||
ok(comp.width() === 1000, 'forced width was removed');
|
||||
ok(comp.height() === 0, 'forced height was removed');
|
||||
});
|
||||
|
@ -155,6 +155,14 @@ test('should set the width and height of the player', function(){
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('should not force width and height', function() {
|
||||
var player = PlayerTest.makePlayer({ width: 'auto', height: 'auto' });
|
||||
ok(player.el().style.width === '', 'Width is not forced');
|
||||
ok(player.el().style.height === '', 'Height is not forced');
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('should accept options from multiple sources and override in correct order', function(){
|
||||
var tag = PlayerTest.makeTag();
|
||||
var container = document.createElement('div');
|
||||
|
Loading…
x
Reference in New Issue
Block a user