Merge pull request #4200 from marcjansen/no-object-get
Do not use goog.object.get
This commit is contained in:
+18
-16
@@ -11,7 +11,6 @@ goog.require('goog.array');
|
|||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.dom.NodeType');
|
goog.require('goog.dom.NodeType');
|
||||||
goog.require('goog.math');
|
goog.require('goog.math');
|
||||||
goog.require('goog.object');
|
|
||||||
goog.require('goog.string');
|
goog.require('goog.string');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
@@ -487,7 +486,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
|||||||
var styleObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
var styleObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(goog.isObject(styleObject),
|
goog.asserts.assert(goog.isObject(styleObject),
|
||||||
'styleObject should be an Object');
|
'styleObject should be an Object');
|
||||||
var IconObject = /** @type {Object} */ (goog.object.get(object, 'Icon', {}));
|
var IconObject = 'Icon' in object ? object['Icon'] : {};
|
||||||
var src;
|
var src;
|
||||||
var href = /** @type {string|undefined} */
|
var href = /** @type {string|undefined} */
|
||||||
(IconObject['href']);
|
(IconObject['href']);
|
||||||
@@ -583,7 +582,7 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) {
|
|||||||
var textStyle = new ol.style.Text({
|
var textStyle = new ol.style.Text({
|
||||||
fill: new ol.style.Fill({
|
fill: new ol.style.Fill({
|
||||||
color: /** @type {ol.Color} */
|
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} */
|
scale: /** @type {number|undefined} */
|
||||||
(object['scale'])
|
(object['scale'])
|
||||||
@@ -617,8 +616,8 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) {
|
|||||||
'styleObject should be an Object');
|
'styleObject should be an Object');
|
||||||
var strokeStyle = new ol.style.Stroke({
|
var strokeStyle = new ol.style.Stroke({
|
||||||
color: /** @type {ol.Color} */
|
color: /** @type {ol.Color} */
|
||||||
(goog.object.get(object, 'color', ol.format.KML.DEFAULT_COLOR_)),
|
('color' in object ? object['color'] : ol.format.KML.DEFAULT_COLOR_),
|
||||||
width: /** @type {number} */ (goog.object.get(object, 'width', 1))
|
width: /** @type {number} */ ('width' in object ? object['width'] : 1)
|
||||||
});
|
});
|
||||||
styleObject['strokeStyle'] = strokeStyle;
|
styleObject['strokeStyle'] = strokeStyle;
|
||||||
};
|
};
|
||||||
@@ -645,7 +644,7 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
|
|||||||
'styleObject should be an Object');
|
'styleObject should be an Object');
|
||||||
var fillStyle = new ol.style.Fill({
|
var fillStyle = new ol.style.Fill({
|
||||||
color: /** @type {ol.Color} */
|
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;
|
styleObject['fillStyle'] = fillStyle;
|
||||||
var fill = /** @type {boolean|undefined} */ (object['fill']);
|
var fill = /** @type {boolean|undefined} */ (object['fill']);
|
||||||
@@ -1015,19 +1014,22 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
|
|||||||
if (!styleObject) {
|
if (!styleObject) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var fillStyle = /** @type {ol.style.Fill} */ (goog.object.get(
|
var fillStyle = /** @type {ol.style.Fill} */
|
||||||
styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_));
|
('fillStyle' in styleObject ?
|
||||||
var fill = /** @type {boolean|undefined} */
|
styleObject['fillStyle'] : ol.format.KML.DEFAULT_FILL_STYLE_);
|
||||||
(styleObject['fill']);
|
var fill = /** @type {boolean|undefined} */ (styleObject['fill']);
|
||||||
if (fill !== undefined && !fill) {
|
if (fill !== undefined && !fill) {
|
||||||
fillStyle = null;
|
fillStyle = null;
|
||||||
}
|
}
|
||||||
var imageStyle = /** @type {ol.style.Image} */ (goog.object.get(
|
var imageStyle = /** @type {ol.style.Image} */
|
||||||
styleObject, 'imageStyle', ol.format.KML.DEFAULT_IMAGE_STYLE_));
|
('imageStyle' in styleObject ?
|
||||||
var textStyle = /** @type {ol.style.Text} */ (goog.object.get(
|
styleObject['imageStyle'] : ol.format.KML.DEFAULT_IMAGE_STYLE_);
|
||||||
styleObject, 'textStyle', ol.format.KML.DEFAULT_TEXT_STYLE_));
|
var textStyle = /** @type {ol.style.Text} */
|
||||||
var strokeStyle = /** @type {ol.style.Stroke} */ (goog.object.get(
|
('textStyle' in styleObject ?
|
||||||
styleObject, 'strokeStyle', ol.format.KML.DEFAULT_STROKE_STYLE_));
|
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} */
|
var outline = /** @type {boolean|undefined} */
|
||||||
(styleObject['outline']);
|
(styleObject['outline']);
|
||||||
if (outline !== undefined && !outline) {
|
if (outline !== undefined && !outline) {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ goog.provide('ol.pointer.PointerEvent');
|
|||||||
|
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.Event');
|
goog.require('goog.events.Event');
|
||||||
goog.require('goog.object');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -76,72 +75,73 @@ ol.pointer.PointerEvent = function(type, browserEvent, opt_eventDict) {
|
|||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.bubbles = goog.object.get(eventDict, 'bubbles', false);
|
this.bubbles = 'bubbles' in eventDict ? eventDict['bubbles'] : false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.cancelable = goog.object.get(eventDict, 'cancelable', false);
|
this.cancelable = 'cancelable' in eventDict ? eventDict['cancelable'] : false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object}
|
* @type {Object}
|
||||||
*/
|
*/
|
||||||
this.view = goog.object.get(eventDict, 'view', null);
|
this.view = 'view' in eventDict ? eventDict['view'] : null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.detail = goog.object.get(eventDict, 'detail', null);
|
this.detail = 'detail' in eventDict ? eventDict['detail'] : null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.screenX = goog.object.get(eventDict, 'screenX', 0);
|
this.screenX = 'screenX' in eventDict ? eventDict['screenX'] : 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.screenY = goog.object.get(eventDict, 'screenY', 0);
|
this.screenY = 'screenY' in eventDict ? eventDict['screenY'] : 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.clientX = goog.object.get(eventDict, 'clientX', 0);
|
this.clientX = 'clientX' in eventDict ? eventDict['clientX'] : 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.clientY = goog.object.get(eventDict, 'clientY', 0);
|
this.clientY = 'clientY' in eventDict ? eventDict['clientY'] : 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.ctrlKey = goog.object.get(eventDict, 'ctrlKey', false);
|
this.ctrlKey = 'ctrlKey' in eventDict ? eventDict['ctrlKey'] : false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.altKey = goog.object.get(eventDict, 'altKey', false);
|
this.altKey = 'altKey' in eventDict ? eventDict['altKey'] : false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.shiftKey = goog.object.get(eventDict, 'shiftKey', false);
|
this.shiftKey = 'shiftKey' in eventDict ? eventDict['shiftKey'] : false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.metaKey = goog.object.get(eventDict, 'metaKey', false);
|
this.metaKey = 'metaKey' in eventDict ? eventDict['metaKey'] : false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.button = goog.object.get(eventDict, 'button', 0);
|
this.button = 'button' in eventDict ? eventDict['button'] : 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Node}
|
* @type {Node}
|
||||||
*/
|
*/
|
||||||
this.relatedTarget = goog.object.get(eventDict, 'relatedTarget', null);
|
this.relatedTarget = 'relatedTarget' in eventDict ?
|
||||||
|
eventDict['relatedTarget'] : null;
|
||||||
|
|
||||||
// PointerEvent related properties
|
// PointerEvent related properties
|
||||||
|
|
||||||
@@ -149,42 +149,42 @@ ol.pointer.PointerEvent = function(type, browserEvent, opt_eventDict) {
|
|||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.pointerId = goog.object.get(eventDict, 'pointerId', 0);
|
this.pointerId = 'pointerId' in eventDict ? eventDict['pointerId'] : 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.width = goog.object.get(eventDict, 'width', 0);
|
this.width = 'width' in eventDict ? eventDict['width'] : 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.height = goog.object.get(eventDict, 'height', 0);
|
this.height = 'height' in eventDict ? eventDict['height'] : 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.tiltX = goog.object.get(eventDict, 'tiltX', 0);
|
this.tiltX = 'tiltX' in eventDict ? eventDict['tiltX'] : 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.tiltY = goog.object.get(eventDict, 'tiltY', 0);
|
this.tiltY = 'tiltY' in eventDict ? eventDict['tiltY'] : 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.pointerType = goog.object.get(eventDict, 'pointerType', '');
|
this.pointerType = 'pointerType' in eventDict ? eventDict['pointerType'] : '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.hwTimestamp = goog.object.get(eventDict, 'hwTimestamp', 0);
|
this.hwTimestamp = 'hwTimestamp' in eventDict ? eventDict['hwTimestamp'] : 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.isPrimary = goog.object.get(eventDict, 'isPrimary', false);
|
this.isPrimary = 'isPrimary' in eventDict ? eventDict['isPrimary'] : false;
|
||||||
|
|
||||||
// keep the semantics of preventDefault
|
// keep the semantics of preventDefault
|
||||||
if (browserEvent.preventDefault) {
|
if (browserEvent.preventDefault) {
|
||||||
|
|||||||
Reference in New Issue
Block a user