Skip to content

Commit

Permalink
Merge pull request #5551 from Rudraksha20/defaultValueCheckNull
Browse files Browse the repository at this point in the history
defaultValue check for null
  • Loading branch information
Hannah authored Jun 28, 2017
2 parents 103c68c + 96e75ad commit 4c14f16
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Change Log
* Fixed a bug where camera zooming worked incorrectly when the display height was greater than the display width [#5421](https://github.com/AnalyticalGraphicsInc/cesium/pull/5421)
* Updated glTF/glb MIME types. [#5420](https://github.com/AnalyticalGraphicsInc/cesium/issues/5420)
* Added `Cesium.Math.randomBetween`.
* Modified `defaultValue` to check for both `undefined` and `null`. [#5551](https://github.com/AnalyticalGraphicsInc/cesium/pull/5551)

### 1.34 - 2017-06-01

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/defaultValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define([
* param = Cesium.defaultValue(param, 'default');
*/
function defaultValue(a, b) {
if (a !== undefined) {
if (a !== undefined && a !== null) {
return a;
}
return b;
Expand Down
20 changes: 20 additions & 0 deletions Specs/Core/defaultValueSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*global defineSuite*/
defineSuite([
'Core/defaultValue'
], function(
defaultValue) {
'use strict';

it('Works with first parameter undefined', function() {
expect(defaultValue(undefined, 5)).toEqual(5);
});

it('Works with first parameter null', function() {
expect(defaultValue(null, 5)).toEqual(5);
});

it('Works with first parameter not undefined and not null', function() {
expect(defaultValue(1, 5)).toEqual(1);
});

});

0 comments on commit 4c14f16

Please sign in to comment.