From c4d5036878d81a3b38e7117d4fcdef095ed41ce0 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 30 Sep 2015 22:27:39 +0200 Subject: [PATCH] Do not use goog.object.get --- src/ol/format/kmlformat.js | 34 +++++++++++++------------ src/ol/pointer/pointerevent.js | 46 +++++++++++++++++----------------- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index dc401f94c6..5636b7ce61 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -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) { diff --git a/src/ol/pointer/pointerevent.js b/src/ol/pointer/pointerevent.js index 74e92f359f..1905250ea0 100644 --- a/src/ol/pointer/pointerevent.js +++ b/src/ol/pointer/pointerevent.js @@ -33,7 +33,6 @@ goog.provide('ol.pointer.PointerEvent'); goog.require('goog.events'); goog.require('goog.events.Event'); -goog.require('goog.object'); @@ -76,72 +75,73 @@ ol.pointer.PointerEvent = function(type, browserEvent, opt_eventDict) { /** * @type {boolean} */ - this.bubbles = goog.object.get(eventDict, 'bubbles', false); + this.bubbles = 'bubbles' in eventDict ? eventDict['bubbles'] : false; /** * @type {boolean} */ - this.cancelable = goog.object.get(eventDict, 'cancelable', false); + this.cancelable = 'cancelable' in eventDict ? eventDict['cancelable'] : false; /** * @type {Object} */ - this.view = goog.object.get(eventDict, 'view', null); + this.view = 'view' in eventDict ? eventDict['view'] : null; /** * @type {number} */ - this.detail = goog.object.get(eventDict, 'detail', null); + this.detail = 'detail' in eventDict ? eventDict['detail'] : null; /** * @type {number} */ - this.screenX = goog.object.get(eventDict, 'screenX', 0); + this.screenX = 'screenX' in eventDict ? eventDict['screenX'] : 0; /** * @type {number} */ - this.screenY = goog.object.get(eventDict, 'screenY', 0); + this.screenY = 'screenY' in eventDict ? eventDict['screenY'] : 0; /** * @type {number} */ - this.clientX = goog.object.get(eventDict, 'clientX', 0); + this.clientX = 'clientX' in eventDict ? eventDict['clientX'] : 0; /** * @type {number} */ - this.clientY = goog.object.get(eventDict, 'clientY', 0); + this.clientY = 'clientY' in eventDict ? eventDict['clientY'] : 0; /** * @type {boolean} */ - this.ctrlKey = goog.object.get(eventDict, 'ctrlKey', false); + this.ctrlKey = 'ctrlKey' in eventDict ? eventDict['ctrlKey'] : false; /** * @type {boolean} */ - this.altKey = goog.object.get(eventDict, 'altKey', false); + this.altKey = 'altKey' in eventDict ? eventDict['altKey'] : false; /** * @type {boolean} */ - this.shiftKey = goog.object.get(eventDict, 'shiftKey', false); + this.shiftKey = 'shiftKey' in eventDict ? eventDict['shiftKey'] : false; /** * @type {boolean} */ - this.metaKey = goog.object.get(eventDict, 'metaKey', false); + this.metaKey = 'metaKey' in eventDict ? eventDict['metaKey'] : false; /** * @type {number} */ - this.button = goog.object.get(eventDict, 'button', 0); + this.button = 'button' in eventDict ? eventDict['button'] : 0; /** * @type {Node} */ - this.relatedTarget = goog.object.get(eventDict, 'relatedTarget', null); + this.relatedTarget = 'relatedTarget' in eventDict ? + eventDict['relatedTarget'] : null; // PointerEvent related properties @@ -149,42 +149,42 @@ ol.pointer.PointerEvent = function(type, browserEvent, opt_eventDict) { * @const * @type {number} */ - this.pointerId = goog.object.get(eventDict, 'pointerId', 0); + this.pointerId = 'pointerId' in eventDict ? eventDict['pointerId'] : 0; /** * @type {number} */ - this.width = goog.object.get(eventDict, 'width', 0); + this.width = 'width' in eventDict ? eventDict['width'] : 0; /** * @type {number} */ - this.height = goog.object.get(eventDict, 'height', 0); + this.height = 'height' in eventDict ? eventDict['height'] : 0; /** * @type {number} */ - this.tiltX = goog.object.get(eventDict, 'tiltX', 0); + this.tiltX = 'tiltX' in eventDict ? eventDict['tiltX'] : 0; /** * @type {number} */ - this.tiltY = goog.object.get(eventDict, 'tiltY', 0); + this.tiltY = 'tiltY' in eventDict ? eventDict['tiltY'] : 0; /** * @type {string} */ - this.pointerType = goog.object.get(eventDict, 'pointerType', ''); + this.pointerType = 'pointerType' in eventDict ? eventDict['pointerType'] : ''; /** * @type {number} */ - this.hwTimestamp = goog.object.get(eventDict, 'hwTimestamp', 0); + this.hwTimestamp = 'hwTimestamp' in eventDict ? eventDict['hwTimestamp'] : 0; /** * @type {boolean} */ - this.isPrimary = goog.object.get(eventDict, 'isPrimary', false); + this.isPrimary = 'isPrimary' in eventDict ? eventDict['isPrimary'] : false; // keep the semantics of preventDefault if (browserEvent.preventDefault) {