Adaptation of previous changes to the change from 61241e7 (null instead of undefined as the initial value)

This commit is contained in:
Michał Zielański
2020-06-24 09:54:56 +02:00
parent 61241e7f90
commit 235babfd7f
4 changed files with 12 additions and 7 deletions

View File

@@ -129,7 +129,7 @@ class Feature extends BaseObject {
*/ */
clone() { clone() {
const clone = new Feature( const clone = new Feature(
this.hasProperties() ? this.getProperties() : undefined this.hasProperties() ? this.getProperties() : null
); );
clone.setGeometryName(this.getGeometryName()); clone.setGeometryName(this.getGeometryName());
const geometry = this.getGeometry(); const geometry = this.getGeometry();

View File

@@ -95,7 +95,7 @@ class BaseObject extends Observable {
/** /**
* @private * @private
* @type {!Object<string, *>} * @type {?Object<string, *>}
*/ */
this.values_ = null; this.values_ = null;
@@ -199,7 +199,7 @@ class BaseObject extends Observable {
const oldValue = this.values_[key]; const oldValue = this.values_[key];
delete this.values_[key]; delete this.values_[key];
if (isEmpty(this.values_)) { if (isEmpty(this.values_)) {
delete this.values_; this.values_ = null;
} }
if (!opt_silent) { if (!opt_silent) {
this.notify(key, oldValue); this.notify(key, oldValue);

View File

@@ -40,19 +40,19 @@ class Target extends Disposable {
/** /**
* @private * @private
* @type {Object<string, number>} * @type {?Object<string, number>}
*/ */
this.pendingRemovals_ = null; this.pendingRemovals_ = null;
/** /**
* @private * @private
* @type {Object<string, number>} * @type {?Object<string, number>}
*/ */
this.dispatching_ = null; this.dispatching_ = null;
/** /**
* @private * @private
* @type {Object<string, Array<import("../events.js").Listener>>} * @type {?Object<string, Array<import("../events.js").Listener>>}
*/ */
this.listeners_ = null; this.listeners_ = null;
} }
@@ -143,7 +143,7 @@ class Target extends Disposable {
* @return {Array<import("../events.js").Listener>|undefined} Listeners. * @return {Array<import("../events.js").Listener>|undefined} Listeners.
*/ */
getListeners(type) { getListeners(type) {
return this.listeners_ && this.listeners_[type]; return (this.listeners_ && this.listeners_[type]) || undefined;
} }
/** /**

View File

@@ -33,6 +33,11 @@ describe('ol.events.EventTarget', function () {
}); });
target.dispatchEvent('my-event'); target.dispatchEvent('my-event');
}); });
it('does not initialize objects in advance', function () {
expect(eventTarget.pendingRemovals_).to.be(null);
expect(eventTarget.dispatching_).to.be(null);
expect(eventTarget.listeners_).to.be(null);
});
}); });
describe('#hasListener', function () { describe('#hasListener', function () {