Convert ol.CollectionEvent#getElement method into element property

This commit is contained in:
Tom Payne
2014-01-23 18:30:36 +01:00
parent 1e52d30d59
commit 3d68a3550e
6 changed files with 28 additions and 29 deletions

View File

@@ -11,5 +11,3 @@
@exportProperty ol.Collection.prototype.remove
@exportProperty ol.Collection.prototype.removeAt
@exportProperty ol.Collection.prototype.setAt
@exportProperty ol.CollectionEvent.prototype.getElement

View File

@@ -26,32 +26,24 @@ ol.CollectionEventType = {
/**
* @constructor
* @extends {goog.events.Event}
* @implements {oli.CollectionEvent}
* @param {ol.CollectionEventType} type Type.
* @param {*=} opt_elem Element.
* @param {*=} opt_element Element.
* @param {Object=} opt_target Target.
*/
ol.CollectionEvent = function(type, opt_elem, opt_target) {
ol.CollectionEvent = function(type, opt_element, opt_target) {
goog.base(this, type, opt_target);
/**
* @private
* @type {*}
*/
this.elem_ = opt_elem;
this.element = opt_element;
};
goog.inherits(ol.CollectionEvent, goog.events.Event);
/**
* @return {*} The element to which this event pertains.
*/
ol.CollectionEvent.prototype.getElement = function() {
return this.elem_;
};
/**
* @enum {string}
*/

View File

@@ -120,7 +120,7 @@ ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
* @private
*/
ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
var layer = /** @type {ol.layer.Base} */ (collectionEvent.getElement());
var layer = /** @type {ol.layer.Base} */ (collectionEvent.element);
this.listenerKeys_[goog.getUid(layer).toString()] = goog.events.listen(
layer, [ol.ObjectEventType.PROPERTYCHANGE, goog.events.EventType.CHANGE],
this.handleLayerChange_, false, this);
@@ -133,7 +133,7 @@ ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
* @private
*/
ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) {
var layer = /** @type {ol.layer.Base} */ (collectionEvent.getElement());
var layer = /** @type {ol.layer.Base} */ (collectionEvent.element);
var key = goog.getUid(layer).toString();
goog.events.unlistenByKey(this.listenerKeys_[key]);
delete this.listenerKeys_[key];

View File

@@ -110,7 +110,7 @@ ol.render.FeaturesOverlay.prototype.handleFeatureChange_ = function() {
ol.render.FeaturesOverlay.prototype.handleFeaturesAdd_ =
function(collectionEvent) {
goog.asserts.assert(!goog.isNull(this.featureChangeListenerKeys_));
var feature = /** @type {ol.Feature} */ (collectionEvent.getElement());
var feature = /** @type {ol.Feature} */ (collectionEvent.element);
this.featureChangeListenerKeys_[goog.getUid(feature).toString()] =
goog.events.listen(feature, goog.events.EventType.CHANGE,
this.handleFeatureChange_, false, this);
@@ -125,7 +125,7 @@ ol.render.FeaturesOverlay.prototype.handleFeaturesAdd_ =
ol.render.FeaturesOverlay.prototype.handleFeaturesRemove_ =
function(collectionEvent) {
goog.asserts.assert(!goog.isNull(this.featureChangeListenerKeys_));
var feature = /** @type {ol.Feature} */ (collectionEvent.getElement());
var feature = /** @type {ol.Feature} */ (collectionEvent.element);
var key = goog.getUid(feature).toString();
goog.events.unlistenByKey(this.featureChangeListenerKeys_[key]);
delete this.featureChangeListenerKeys_[key];