simplify the assignment of this.target_
This commit is contained in:
@@ -30,12 +30,10 @@ ol.control.Control = function(options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Element|undefined}
|
||||
* @type {?Element}
|
||||
*/
|
||||
this.target_ = goog.isDef(options.target) ? (goog.isString(options.target) ?
|
||||
goog.dom.getElement(options.target) !== null ?
|
||||
goog.dom.getElement(options.target) : undefined : options.target) :
|
||||
undefined;
|
||||
this.target_ = goog.isDef(options.target) ?
|
||||
goog.dom.getElement(options.target) : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -98,7 +96,7 @@ ol.control.Control.prototype.setMap = function(map) {
|
||||
}
|
||||
this.map_ = map;
|
||||
if (!goog.isNull(this.map_)) {
|
||||
var target = goog.isDef(this.target_) ?
|
||||
var target = !goog.isNull(this.target_) ?
|
||||
this.target_ : map.getOverlayContainerStopEvent();
|
||||
goog.dom.appendChild(target, this.element);
|
||||
if (this.handleMapPostrender !== goog.nullFunction) {
|
||||
|
||||
@@ -42,7 +42,7 @@ describe('ol.control.Control\'s target', function() {
|
||||
});
|
||||
it('ignores non-existing target id', function() {
|
||||
var ctrl = new ol.control.Control({target: 'doesnotexist'});
|
||||
expect(ctrl.target_).to.equal(undefined);
|
||||
expect(ctrl.target_).to.equal(null);
|
||||
goog.dispose(ctrl);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user