Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated defaultValue.EMPTY_OBJECT and created EmptyObject standalone constant #12238

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

##### Deprecated :hourglass_flowing_sand:

- `defaultValue.EMPTY_OBJECT` has been deprecated and will be removed in 1.125. Use `EmptyObject` instead.

### 1.122 - 2024-10-01

#### @cesium/engine
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu

## [Individual CLA](Documentation/Contributors/CLAs/individual-contributor-license-agreement-v1.0.pdf)

- [Paul An](https://github.com/anpaulan)
- [Brandon Landry](https://github.com/hotpocket)
- [Victor Berchet](https://github.com/vicb)
- [Caleb Morse](https://github.com/cmorse)
Expand Down
8 changes: 8 additions & 0 deletions packages/engine/Source/Core/EmptyObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* A global immutable empty object for performance reasons
*
* @type {object}
*/
const EmptyObject = {};

export default Object.freeze(EmptyObject);
23 changes: 18 additions & 5 deletions packages/engine/Source/Core/defaultValue.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import EmptyObject from "./EmptyObject.js";
import deprecationWarning from "./deprecationWarning.js";

/**
* Returns the first parameter if not undefined, otherwise the second parameter.
* Useful for setting a default value for a parameter.
*
* @function
*
* @param {*} a
Expand All @@ -10,6 +12,9 @@
*
* @example
* param = Cesium.defaultValue(param, 'default');
*
* @property {object} EMPTY_OBJECT - DEPRECATED (use EmptyObject). <br>
* A frozen empty object that can be used as the default value for options passed as an object literal.
*/
function defaultValue(a, b) {
if (a !== undefined && a !== null) {
Expand All @@ -19,11 +24,19 @@ function defaultValue(a, b) {
}

/**
* A frozen empty object that can be used as the default value for options passed as
* an object literal.
* @type {object}
* @memberof defaultValue
* @constant
* @deprecated This property is deprecated and will be removed in Cesium 1.125. See <a href="https://github.com/CesiumGS/cesium/issues/11326">Issue 113216</a>
*/
defaultValue.EMPTY_OBJECT = Object.freeze({});
Object.defineProperty(defaultValue, "EMPTY_OBJECT", {
get: function () {
deprecationWarning(
"defaultValue.EMPTY_OBJECT",
"defaultValue.EMPTY_OBJECT is deprecated and will be removed in Cesium 1.125. See https://github.com/CesiumGS/cesium/issues/11326",
);
return EmptyObject;
},
configurable: false,
});

export default defaultValue;