Use `self` instead of `this` as much as possible (except short code)
MODIFY
www/Circle.js
www/Circle.js
@@ -143,13 +143,14 @@ Circle.prototype.setRadius = function(radius) {
};
Circle.prototype.remove = function() {
- this.trigger(this.id + "_remove");
- exec.call(this, null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ var self = this;
+ self.trigger(self.id + "_remove");
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'remove', [self.getId()]);
Object.defineProperty(self, "_isRemoved", {
value: true,
writable: false
});
- this.destroy();
+ self.destroy();
};
Circle.prototype.getBounds = function() {

MODIFY
www/GroundOverlay.js
www/GroundOverlay.js
@@ -146,13 +146,13 @@ GroundOverlay.prototype.getClickable = function() {
};
GroundOverlay.prototype.remove = function() {
- this.trigger(this.id + "_remove");
- exec.call(this, null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ self.trigger(self.id + "_remove");
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'remove', [self.getId()]);
Object.defineProperty(self, "_isRemoved", {
value: true,
writable: false
});
- this.destroy();
+ self.destroy();
};

MODIFY
www/Map.js
www/Map.js
@@ -563,7 +563,7 @@ Map.prototype.remove = function(callback) {
clearObj(self.MARKERS);
clearObj(self.KML_LAYERS);
- exec.call(this, function() {
+ exec.call(self, function() {
if (typeof callback === "function") {
callback.call(self);
}

MODIFY
www/Marker.js
www/Marker.js
@@ -114,13 +114,13 @@ Marker.prototype.remove = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.getPluginName(), 'remove', [this.getId()]);
+ }, self.errorHandler, self.getPluginName(), 'remove', [self.getId()]);
Object.defineProperty(self, "_isRemoved", {
value: true,
writable: false
});
- this.destroy();
+ self.destroy();
};
Marker.prototype.getOptions = function() {

MODIFY
www/Polygon.js
www/Polygon.js
@@ -127,13 +127,14 @@ var Polygon = function(map, polygonId, polygonOptions, _exec) {
utils.extend(Polygon, BaseClass);
Polygon.prototype.remove = function() {
- this.trigger(this.id + "_remove");
- exec.call(this, null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ var self = self;
+ self.trigger(this.id + "_remove");
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'remove', [self.getId()]);
Object.defineProperty(self, "_isRemoved", {
value: true,
writable: false
});
- this.destroy();
+ self.destroy();
};
Polygon.prototype.getPluginName = function() {
return this.map.getId() + "-polygon";

MODIFY
www/Polyline.js
www/Polyline.js
@@ -166,9 +166,10 @@ Polyline.prototype.getMap = function() {
};
Polyline.prototype.remove = function() {
- exec.call(this, null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
- this.trigger(this.id + "_remove");
- var points = this.get("points");
+ var self = this;
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'remove', [self.getId()]);
+ self.trigger(self.id + "_remove");
+ var points = self.get("points");
if (points) {
points.clear();
}
@@ -176,6 +177,6 @@ Polyline.prototype.remove = function() {
value: true,
writable: false
});
- this.destroy();
+ self.destroy();
};
module.exports = Polyline;

MODIFY
www/TileOverlay.js
www/TileOverlay.js
@@ -107,13 +107,14 @@ TileOverlay.prototype.getVisible = function() {
};
TileOverlay.prototype.remove = function() {
- this.trigger(this.id + "_remove");
- exec.call(this, null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ var self = this;
+ self.trigger(self.id + "_remove");
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'remove', [self.getId()]);
Object.defineProperty(self, "_isRemoved", {
value: true,
writable: false
});
- this.destroy();
+ self.destroy();
};
module.exports = TileOverlay;

Use `self` instead of `this` as much as possible (except short code)
#1804