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

Prevent error when name is null or undefined (fixes #8804) #8832

1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Fixed a bug where switching from perspective to orthographic caused triangles to overlap each other incorrectly. [#8346](https://github.com/CesiumGS/cesium/issues/8346)
- Fixed a bug where switching to orthographic camera on the first frame caused the zoom level to be incorrect. [#8853](https://github.com/CesiumGS/cesium/pull/8853)
- Fixed `scene.pickFromRay` intersection inaccuracies. [#8439](https://github.com/CesiumGS/cesium/issues/8439)
- Fixed a bug where a null or undefined name property passed to the `Entity` constructor would throw an exception.[#8832](https://github.com/CesiumGS/cesium/pull/8832)

### 1.70.1 - 2020-06-10

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Wang Bao](https://github.com/xiaobaogeit)
- [John Remsberg](https://github.com/easternmotors)
- [Bao Thien Tran](https://github.com/baothientran)
- [Yonatan Kra](https://github.com/yonatankra)
6 changes: 4 additions & 2 deletions Source/DataSources/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,10 @@ Entity.prototype.merge = function (source) {
for (var i = 0; i < propertyNamesLength; i++) {
var name = sourcePropertyNames[i];

//Ignore parent when merging, this only happens at construction time.
if (name === "parent") {
//While source is required by the API to be an Entity, we internally call this method from the
//constructor with an options object to configure initial custom properties.
//So we need to ignore reserved-non-property.
if (name === "parent" || name === "name" || name === "availability") {
continue;
}

Expand Down
15 changes: 15 additions & 0 deletions Specs/DataSources/EntitySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,21 @@ describe("DataSources/Entity", function () {
}
});

it("merge ignores reserved property names when called with a plain object.", function () {
var entity = new Entity();

//Technically merge requires passing an Entity instance, but we call it internally
//with a plain object during construction to set up custom properties.
entity.merge({
name: undefined,
availability: undefined,
parent: undefined,
});
expect(entity.name).toBeUndefined();
expect(entity.availability).toBeUndefined();
expect(entity.parent).toBeUndefined();
});

it("merge does not overwrite availability", function () {
var entity = new Entity();
var interval = TimeInterval.fromIso8601({
Expand Down