Do not use goog.object.get

This commit is contained in:
Marc Jansen
2015-09-30 22:27:39 +02:00
parent e6c5fa9cd7
commit c4d5036878
2 changed files with 41 additions and 39 deletions

View File

@@ -11,7 +11,6 @@ goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.dom.NodeType');
goog.require('goog.math');
goog.require('goog.object');
goog.require('goog.string');
goog.require('ol');
goog.require('ol.Feature');
@@ -487,7 +486,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
var styleObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isObject(styleObject),
'styleObject should be an Object');
var IconObject = /** @type {Object} */ (goog.object.get(object, 'Icon', {}));
var IconObject = 'Icon' in object ? object['Icon'] : {};
var src;
var href = /** @type {string|undefined} */
(IconObject['href']);
@@ -583,7 +582,7 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) {
var textStyle = new ol.style.Text({
fill: new ol.style.Fill({
color: /** @type {ol.Color} */
(goog.object.get(object, 'color', ol.format.KML.DEFAULT_COLOR_))
('color' in object ? object['color'] : ol.format.KML.DEFAULT_COLOR_)
}),
scale: /** @type {number|undefined} */
(object['scale'])
@@ -617,8 +616,8 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) {
'styleObject should be an Object');
var strokeStyle = new ol.style.Stroke({
color: /** @type {ol.Color} */
(goog.object.get(object, 'color', ol.format.KML.DEFAULT_COLOR_)),
width: /** @type {number} */ (goog.object.get(object, 'width', 1))
('color' in object ? object['color'] : ol.format.KML.DEFAULT_COLOR_),
width: /** @type {number} */ ('width' in object ? object['width'] : 1)
});
styleObject['strokeStyle'] = strokeStyle;
};
@@ -645,7 +644,7 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
'styleObject should be an Object');
var fillStyle = new ol.style.Fill({
color: /** @type {ol.Color} */
(goog.object.get(object, 'color', ol.format.KML.DEFAULT_COLOR_))
('color' in object ? object['color'] : ol.format.KML.DEFAULT_COLOR_)
});
styleObject['fillStyle'] = fillStyle;
var fill = /** @type {boolean|undefined} */ (object['fill']);
@@ -1015,19 +1014,22 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
if (!styleObject) {
return null;
}
var fillStyle = /** @type {ol.style.Fill} */ (goog.object.get(
styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_));
var fill = /** @type {boolean|undefined} */
(styleObject['fill']);
var fillStyle = /** @type {ol.style.Fill} */
('fillStyle' in styleObject ?
styleObject['fillStyle'] : ol.format.KML.DEFAULT_FILL_STYLE_);
var fill = /** @type {boolean|undefined} */ (styleObject['fill']);
if (fill !== undefined && !fill) {
fillStyle = null;
}
var imageStyle = /** @type {ol.style.Image} */ (goog.object.get(
styleObject, 'imageStyle', ol.format.KML.DEFAULT_IMAGE_STYLE_));
var textStyle = /** @type {ol.style.Text} */ (goog.object.get(
styleObject, 'textStyle', ol.format.KML.DEFAULT_TEXT_STYLE_));
var strokeStyle = /** @type {ol.style.Stroke} */ (goog.object.get(
styleObject, 'strokeStyle', ol.format.KML.DEFAULT_STROKE_STYLE_));
var imageStyle = /** @type {ol.style.Image} */
('imageStyle' in styleObject ?
styleObject['imageStyle'] : ol.format.KML.DEFAULT_IMAGE_STYLE_);
var textStyle = /** @type {ol.style.Text} */
('textStyle' in styleObject ?
styleObject['textStyle'] : ol.format.KML.DEFAULT_TEXT_STYLE_);
var strokeStyle = /** @type {ol.style.Stroke} */
('strokeStyle' in styleObject ?
styleObject['strokeStyle'] : ol.format.KML.DEFAULT_STROKE_STYLE_);
var outline = /** @type {boolean|undefined} */
(styleObject['outline']);
if (outline !== undefined && !outline) {