mirror of
https://github.com/videojs/video.js.git
synced 2025-07-17 01:42:41 +02:00
NaN & null should be treated as 0 in dimension()
When dimension() receives a NaN or null value for the number, it will treat it as zero. Updated tests to reflect that as well.
This commit is contained in:
@ -199,7 +199,7 @@ test('should show and hide an element', function(){
|
||||
ok(comp.el().style.display === 'block');
|
||||
});
|
||||
|
||||
test('dimension() should ignore undefined, null, and NaN values', function() {
|
||||
test('dimension() should treat NaN and null as zero', function() {
|
||||
var comp, width, height, newWidth, newHeight;
|
||||
width = 300;
|
||||
height = 150;
|
||||
@ -211,12 +211,17 @@ test('dimension() should ignore undefined, null, and NaN values', function() {
|
||||
|
||||
newWidth = comp.dimension('width', null);
|
||||
|
||||
equal(newWidth, width, 'we did not set the width with null');
|
||||
notEqual(newWidth, width, 'new width and old width are not the same');
|
||||
equal(newWidth, comp, 'we set a value, so, return value is component');
|
||||
equal(comp.width(), 0, 'the new width is zero');
|
||||
|
||||
newHeight = comp.dimension('height', NaN);
|
||||
|
||||
equal(newHeight, height, 'we did not set the height with NaN');
|
||||
notEqual(newHeight, height, 'new height and old height are not the same');
|
||||
equal(newHeight, comp, 'we set a value, so, return value is component');
|
||||
equal(comp.height(), 0, 'the new height is zero');
|
||||
|
||||
comp.width(width);
|
||||
newWidth = comp.dimension('width', undefined);
|
||||
|
||||
equal(newWidth, width, 'we did not set the width with undefined');
|
||||
|
Reference in New Issue
Block a user