Merge pull request #4796 from marcjansen/rm-goog-isstring
Remove use of goog.isString()
This commit is contained in:
@@ -106,7 +106,7 @@ ol.color.asArray = function(color) {
|
||||
if (goog.isArray(color)) {
|
||||
return color;
|
||||
} else {
|
||||
goog.asserts.assert(goog.isString(color), 'Color should be a string');
|
||||
goog.asserts.assert(typeof color === 'string', 'Color should be a string');
|
||||
return ol.color.fromString(color);
|
||||
}
|
||||
};
|
||||
@@ -119,7 +119,7 @@ ol.color.asArray = function(color) {
|
||||
* @api
|
||||
*/
|
||||
ol.color.asString = function(color) {
|
||||
if (goog.isString(color)) {
|
||||
if (typeof color === 'string') {
|
||||
return color;
|
||||
} else {
|
||||
goog.asserts.assert(goog.isArray(color), 'Color should be an array');
|
||||
@@ -322,10 +322,10 @@ ol.color.stringOrColorEquals = function(color1, color2) {
|
||||
if (color1 === color2 || color1 == color2) {
|
||||
return true;
|
||||
}
|
||||
if (goog.isString(color1)) {
|
||||
if (typeof color1 === 'string') {
|
||||
color1 = ol.color.fromString(color1);
|
||||
}
|
||||
if (goog.isString(color2)) {
|
||||
if (typeof color2 === 'string') {
|
||||
color2 = ol.color.fromString(color2);
|
||||
}
|
||||
return ol.color.equals(color1, color2);
|
||||
|
||||
@@ -74,7 +74,7 @@ ol.control.Attribution = function(opt_options) {
|
||||
* @private
|
||||
* @type {Node}
|
||||
*/
|
||||
this.collapseLabel_ = goog.isString(collapseLabel) ?
|
||||
this.collapseLabel_ = typeof collapseLabel === 'string' ?
|
||||
goog.dom.createDom('SPAN', {}, collapseLabel) :
|
||||
collapseLabel;
|
||||
|
||||
@@ -84,7 +84,7 @@ ol.control.Attribution = function(opt_options) {
|
||||
* @private
|
||||
* @type {Node}
|
||||
*/
|
||||
this.label_ = goog.isString(label) ?
|
||||
this.label_ = typeof label === 'string' ?
|
||||
goog.dom.createDom('SPAN', {}, label) :
|
||||
label;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ ol.control.FullScreen = function(opt_options) {
|
||||
* @private
|
||||
* @type {Node}
|
||||
*/
|
||||
this.labelNode_ = goog.isString(label) ?
|
||||
this.labelNode_ = typeof label === 'string' ?
|
||||
document.createTextNode(label) : label;
|
||||
|
||||
var labelActive = options.labelActive ? options.labelActive : '\u00d7';
|
||||
@@ -54,7 +54,7 @@ ol.control.FullScreen = function(opt_options) {
|
||||
* @private
|
||||
* @type {Node}
|
||||
*/
|
||||
this.labelActiveNode_ = goog.isString(labelActive) ?
|
||||
this.labelActiveNode_ = typeof labelActive === 'string' ?
|
||||
document.createTextNode(labelActive) : labelActive;
|
||||
|
||||
var tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
|
||||
|
||||
@@ -62,7 +62,7 @@ ol.control.OverviewMap = function(opt_options) {
|
||||
* @private
|
||||
* @type {Node}
|
||||
*/
|
||||
this.collapseLabel_ = goog.isString(collapseLabel) ?
|
||||
this.collapseLabel_ = typeof collapseLabel === 'string' ?
|
||||
goog.dom.createDom('SPAN', {}, collapseLabel) :
|
||||
collapseLabel;
|
||||
|
||||
@@ -72,7 +72,7 @@ ol.control.OverviewMap = function(opt_options) {
|
||||
* @private
|
||||
* @type {Node}
|
||||
*/
|
||||
this.label_ = goog.isString(label) ?
|
||||
this.label_ = typeof label === 'string' ?
|
||||
goog.dom.createDom('SPAN', {}, label) :
|
||||
label;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ ol.control.Rotate = function(opt_options) {
|
||||
*/
|
||||
this.label_ = null;
|
||||
|
||||
if (goog.isString(label)) {
|
||||
if (typeof label === 'string') {
|
||||
this.label_ = goog.dom.createDom('SPAN',
|
||||
'ol-compass', label);
|
||||
} else {
|
||||
|
||||
@@ -59,7 +59,7 @@ ol.events.EventTarget.prototype.addEventListener = function(type, listener) {
|
||||
* event object or if any of the listeners returned false.
|
||||
*/
|
||||
ol.events.EventTarget.prototype.dispatchEvent = function(event) {
|
||||
var evt = goog.isString(event) ? new ol.events.Event(event) : event;
|
||||
var evt = typeof event === 'string' ? new ol.events.Event(event) : event;
|
||||
var type = evt.type;
|
||||
evt.target = this;
|
||||
var listeners = this.listeners_[type];
|
||||
|
||||
@@ -143,7 +143,7 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
|
||||
context['featureType'] = featureType;
|
||||
context['featureNS'] = featureNS;
|
||||
}
|
||||
if (goog.isString(featureNS)) {
|
||||
if (typeof featureNS === 'string') {
|
||||
var ns = featureNS;
|
||||
featureNS = {};
|
||||
featureNS[defaultPrefix] = ns;
|
||||
|
||||
@@ -29,7 +29,7 @@ goog.inherits(ol.format.JSONFeature, ol.format.Feature);
|
||||
ol.format.JSONFeature.prototype.getObject_ = function(source) {
|
||||
if (goog.isObject(source)) {
|
||||
return source;
|
||||
} else if (goog.isString(source)) {
|
||||
} else if (typeof source === 'string') {
|
||||
var object = goog.json.parse(source);
|
||||
return object ? object : null;
|
||||
} else {
|
||||
|
||||
@@ -431,7 +431,7 @@ ol.format.KML.createFeatureStyleFunction_ = function(style, styleUrl,
|
||||
ol.format.KML.findStyle_ = function(styleValue, defaultStyle, sharedStyles) {
|
||||
if (goog.isArray(styleValue)) {
|
||||
return styleValue;
|
||||
} else if (goog.isString(styleValue)) {
|
||||
} else if (typeof styleValue === 'string') {
|
||||
// KML files in the wild occasionally forget the leading `#` on styleUrls
|
||||
// defined in the same document. Add a leading `#` if it enables to find
|
||||
// a style.
|
||||
@@ -1274,7 +1274,7 @@ ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) {
|
||||
'placemarkObject should be an Object');
|
||||
if (goog.isArray(styleMapValue)) {
|
||||
placemarkObject['Style'] = styleMapValue;
|
||||
} else if (goog.isString(styleMapValue)) {
|
||||
} else if (typeof styleMapValue === 'string') {
|
||||
placemarkObject['styleUrl'] = styleMapValue;
|
||||
} else {
|
||||
goog.asserts.fail('styleMapValue has an unknown type');
|
||||
@@ -1973,7 +1973,7 @@ ol.format.KML.prototype.readName = function(source) {
|
||||
return this.readNameFromDocument(/** @type {Document} */ (source));
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readNameFromNode(/** @type {Node} */ (source));
|
||||
} else if (goog.isString(source)) {
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readNameFromDocument(doc);
|
||||
} else {
|
||||
@@ -2045,7 +2045,7 @@ ol.format.KML.prototype.readNetworkLinks = function(source) {
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
ol.array.extend(networkLinks, this.readNetworkLinksFromNode(
|
||||
/** @type {Node} */ (source)));
|
||||
} else if (goog.isString(source)) {
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = ol.xml.parse(source);
|
||||
ol.array.extend(networkLinks, this.readNetworkLinksFromDocument(doc));
|
||||
} else {
|
||||
|
||||
@@ -26,7 +26,7 @@ goog.inherits(ol.format.TextFeature, ol.format.Feature);
|
||||
* @return {string} Text.
|
||||
*/
|
||||
ol.format.TextFeature.prototype.getText_ = function(source) {
|
||||
if (goog.isString(source)) {
|
||||
if (typeof source === 'string') {
|
||||
return source;
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
|
||||
@@ -151,7 +151,7 @@ ol.format.WFS.prototype.readTransactionResponse = function(source) {
|
||||
/** @type {Document} */ (source));
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readTransactionResponseFromNode(/** @type {Node} */ (source));
|
||||
} else if (goog.isString(source)) {
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readTransactionResponseFromDocument(doc);
|
||||
} else {
|
||||
@@ -176,7 +176,7 @@ ol.format.WFS.prototype.readFeatureCollectionMetadata = function(source) {
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readFeatureCollectionMetadataFromNode(
|
||||
/** @type {Node} */ (source));
|
||||
} else if (goog.isString(source)) {
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readFeatureCollectionMetadataFromDocument(doc);
|
||||
} else {
|
||||
|
||||
@@ -42,7 +42,7 @@ ol.format.XMLFeature.prototype.readFeature = function(source, opt_options) {
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readFeatureFromNode(/** @type {Node} */ (source), opt_options);
|
||||
} else if (goog.isString(source)) {
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readFeatureFromDocument(doc, opt_options);
|
||||
} else {
|
||||
@@ -85,7 +85,7 @@ ol.format.XMLFeature.prototype.readFeatures = function(source, opt_options) {
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readFeaturesFromNode(/** @type {Node} */ (source), opt_options);
|
||||
} else if (goog.isString(source)) {
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readFeaturesFromDocument(doc, opt_options);
|
||||
} else {
|
||||
@@ -133,7 +133,7 @@ ol.format.XMLFeature.prototype.readGeometry = function(source, opt_options) {
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readGeometryFromNode(/** @type {Node} */ (source), opt_options);
|
||||
} else if (goog.isString(source)) {
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readGeometryFromDocument(doc, opt_options);
|
||||
} else {
|
||||
@@ -169,7 +169,7 @@ ol.format.XMLFeature.prototype.readProjection = function(source) {
|
||||
return this.readProjectionFromDocument(/** @type {Document} */ (source));
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readProjectionFromNode(/** @type {Node} */ (source));
|
||||
} else if (goog.isString(source)) {
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readProjectionFromDocument(doc);
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,7 @@ ol.format.XML.prototype.read = function(source) {
|
||||
return this.readFromDocument(/** @type {Document} */ (source));
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readFromNode(/** @type {Node} */ (source));
|
||||
} else if (goog.isString(source)) {
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readFromDocument(doc);
|
||||
} else {
|
||||
|
||||
@@ -94,7 +94,7 @@ ol.layer.Heatmap = function(opt_options) {
|
||||
|
||||
var weight = options.weight ? options.weight : 'weight';
|
||||
var weightFunction;
|
||||
if (goog.isString(weight)) {
|
||||
if (typeof weight === 'string') {
|
||||
weightFunction = function(feature) {
|
||||
return feature.get(weight);
|
||||
};
|
||||
|
||||
@@ -1495,7 +1495,7 @@ ol.Map.createOptionsInternal = function(options) {
|
||||
if (options.keyboardEventTarget !== undefined) {
|
||||
// cannot use goog.dom.getElement because its argument cannot be
|
||||
// of type Document
|
||||
keyboardEventTarget = goog.isString(options.keyboardEventTarget) ?
|
||||
keyboardEventTarget = typeof options.keyboardEventTarget === 'string' ?
|
||||
document.getElementById(options.keyboardEventTarget) :
|
||||
options.keyboardEventTarget;
|
||||
}
|
||||
@@ -1511,7 +1511,7 @@ ol.Map.createOptionsInternal = function(options) {
|
||||
logos[ol.OL3_LOGO_URL] = ol.OL3_URL;
|
||||
} else {
|
||||
var logo = options.logo;
|
||||
if (goog.isString(logo)) {
|
||||
if (typeof logo === 'string') {
|
||||
logos[logo] = '';
|
||||
} else if (goog.isObject(logo)) {
|
||||
goog.asserts.assertString(logo.href, 'logo.href should be a string');
|
||||
@@ -1541,7 +1541,7 @@ ol.Map.createOptionsInternal = function(options) {
|
||||
if (options.renderer !== undefined) {
|
||||
if (goog.isArray(options.renderer)) {
|
||||
rendererTypes = options.renderer;
|
||||
} else if (goog.isString(options.renderer)) {
|
||||
} else if (typeof options.renderer === 'string') {
|
||||
rendererTypes = [options.renderer];
|
||||
} else {
|
||||
goog.asserts.fail('Incorrect format for renderer option');
|
||||
|
||||
@@ -520,7 +520,7 @@ ol.proj.clearAllProjections = function() {
|
||||
ol.proj.createProjection = function(projection, defaultCode) {
|
||||
if (!projection) {
|
||||
return ol.proj.get(defaultCode);
|
||||
} else if (goog.isString(projection)) {
|
||||
} else if (typeof projection === 'string') {
|
||||
return ol.proj.get(projection);
|
||||
} else {
|
||||
goog.asserts.assertInstanceof(projection, ol.proj.Projection,
|
||||
@@ -680,7 +680,7 @@ ol.proj.get = function(projectionLike) {
|
||||
var projection;
|
||||
if (projectionLike instanceof ol.proj.Projection) {
|
||||
projection = projectionLike;
|
||||
} else if (goog.isString(projectionLike)) {
|
||||
} else if (typeof projectionLike === 'string') {
|
||||
var code = projectionLike;
|
||||
projection = ol.proj.projections_[code];
|
||||
if (ol.ENABLE_PROJ4JS) {
|
||||
|
||||
@@ -376,7 +376,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
goog.asserts.assert(goog.isNumber(instruction[2]),
|
||||
'3rd instruction should be a number');
|
||||
dd = /** @type {number} */ (instruction[2]);
|
||||
goog.asserts.assert(goog.isString(instruction[3]),
|
||||
goog.asserts.assert(typeof instruction[3] === 'string',
|
||||
'4th instruction should be a string');
|
||||
text = /** @type {string} */ (instruction[3]);
|
||||
goog.asserts.assert(goog.isNumber(instruction[4]),
|
||||
@@ -497,19 +497,19 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.SET_FILL_STYLE:
|
||||
goog.asserts.assert(goog.isString(instruction[1]),
|
||||
goog.asserts.assert(typeof instruction[1] === 'string',
|
||||
'2nd instruction should be a string');
|
||||
context.fillStyle = /** @type {string} */ (instruction[1]);
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.SET_STROKE_STYLE:
|
||||
goog.asserts.assert(goog.isString(instruction[1]),
|
||||
goog.asserts.assert(typeof instruction[1] === 'string',
|
||||
'2nd instruction should be a string');
|
||||
goog.asserts.assert(goog.isNumber(instruction[2]),
|
||||
'3rd instruction should be a number');
|
||||
goog.asserts.assert(goog.isString(instruction[3]),
|
||||
goog.asserts.assert(typeof instruction[3] === 'string',
|
||||
'4rd instruction should be a string');
|
||||
goog.asserts.assert(goog.isString(instruction[4]),
|
||||
goog.asserts.assert(typeof instruction[4] === 'string',
|
||||
'5th instruction should be a string');
|
||||
goog.asserts.assert(goog.isNumber(instruction[5]),
|
||||
'6th instruction should be a number');
|
||||
@@ -531,11 +531,11 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.SET_TEXT_STYLE:
|
||||
goog.asserts.assert(goog.isString(instruction[1]),
|
||||
goog.asserts.assert(typeof instruction[1] === 'string',
|
||||
'2nd instruction should be a string');
|
||||
goog.asserts.assert(goog.isString(instruction[2]),
|
||||
goog.asserts.assert(typeof instruction[2] === 'string',
|
||||
'3rd instruction should be a string');
|
||||
goog.asserts.assert(goog.isString(instruction[3]),
|
||||
goog.asserts.assert(typeof instruction[3] === 'string',
|
||||
'4th instruction should be a string');
|
||||
context.font = /** @type {string} */ (instruction[1]);
|
||||
context.textAlign = /** @type {string} */ (instruction[2]);
|
||||
|
||||
@@ -222,7 +222,7 @@ ol.renderer.Layer.prototype.updateAttributions = function(attributionsSet, attri
|
||||
ol.renderer.Layer.prototype.updateLogos = function(frameState, source) {
|
||||
var logo = source.getLogo();
|
||||
if (logo !== undefined) {
|
||||
if (goog.isString(logo)) {
|
||||
if (typeof logo === 'string') {
|
||||
frameState.logos[logo] = '';
|
||||
} else if (goog.isObject(logo)) {
|
||||
goog.asserts.assertString(logo.href, 'logo.href is a string');
|
||||
|
||||
@@ -277,7 +277,7 @@ ol.source.TileUTFGridTile_.prototype.getData = function(coordinate) {
|
||||
|
||||
var row = this.grid_[Math.floor((1 - yRelative) * this.grid_.length)];
|
||||
|
||||
if (!goog.isString(row)) {
|
||||
if (typeof row !== 'string') {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ ol.style.Style.prototype.getZIndex = function() {
|
||||
ol.style.Style.prototype.setGeometry = function(geometry) {
|
||||
if (goog.isFunction(geometry)) {
|
||||
this.geometryFunction_ = geometry;
|
||||
} else if (goog.isString(geometry)) {
|
||||
} else if (typeof geometry === 'string') {
|
||||
this.geometryFunction_ = function(feature) {
|
||||
var result = feature.get(geometry);
|
||||
if (result) {
|
||||
|
||||
Reference in New Issue
Block a user