Remove goog.asserts.*
This pull requests replaces type check hint assertions with type casts, library sanity check assertions with conditional console.assert statements in debug mode, and runtime sanity checks with assertions that throw an ol.AssertionError with an error code for lookup outside the library.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.style.Atlas');
|
||||
goog.provide('ol.style.AtlasManager');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.dom');
|
||||
|
||||
@@ -85,9 +84,7 @@ ol.style.AtlasManager.prototype.getInfo = function(id) {
|
||||
if (!info) {
|
||||
return null;
|
||||
}
|
||||
/** @type {?ol.AtlasInfo} */
|
||||
var hitInfo = this.getInfo_(this.hitAtlases_, id);
|
||||
goog.asserts.assert(hitInfo, 'hitInfo must not be null');
|
||||
var hitInfo = /** @type {ol.AtlasInfo} */ (this.getInfo_(this.hitAtlases_, id));
|
||||
|
||||
return this.mergeInfos_(info, hitInfo);
|
||||
};
|
||||
@@ -122,9 +119,9 @@ ol.style.AtlasManager.prototype.getInfo_ = function(atlases, id) {
|
||||
* entry, or `null` if the entry is not part of the atlases.
|
||||
*/
|
||||
ol.style.AtlasManager.prototype.mergeInfos_ = function(info, hitInfo) {
|
||||
goog.asserts.assert(info.offsetX === hitInfo.offsetX,
|
||||
ol.DEBUG && console.assert(info.offsetX === hitInfo.offsetX,
|
||||
'in order to merge, offsetX of info and hitInfo must be equal');
|
||||
goog.asserts.assert(info.offsetY === hitInfo.offsetY,
|
||||
ol.DEBUG && console.assert(info.offsetY === hitInfo.offsetY,
|
||||
'in order to merge, offsetY of info and hitInfo must be equal');
|
||||
return /** @type {ol.AtlasManagerInfo} */ ({
|
||||
offsetX: info.offsetX,
|
||||
@@ -177,10 +174,8 @@ ol.style.AtlasManager.prototype.add = function(id, width, height,
|
||||
var renderHitCallback = opt_renderHitCallback !== undefined ?
|
||||
opt_renderHitCallback : ol.nullFunction;
|
||||
|
||||
/** @type {?ol.AtlasInfo} */
|
||||
var hitInfo = this.add_(true,
|
||||
id, width, height, renderHitCallback, opt_this);
|
||||
goog.asserts.assert(hitInfo, 'hitInfo must not be null');
|
||||
var hitInfo = /** @type {ol.AtlasInfo} */ (this.add_(true,
|
||||
id, width, height, renderHitCallback, opt_this));
|
||||
|
||||
return this.mergeInfos_(info, hitInfo);
|
||||
};
|
||||
@@ -225,7 +220,8 @@ ol.style.AtlasManager.prototype.add_ = function(isHitAtlas, id, width, height,
|
||||
++ii;
|
||||
}
|
||||
}
|
||||
goog.asserts.fail('Failed to add to atlasmanager');
|
||||
ol.DEBUG && console.assert(false, 'Failed to add to atlasmanager');
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user