Merge pull request #7851 from tschaub/named-exports

Replacing static functions with named exports
This commit is contained in:
Tim Schaub
2018-02-19 08:42:52 -07:00
committed by GitHub
17 changed files with 105 additions and 119 deletions
+32 -30
View File
@@ -17,6 +17,33 @@ const Property = {
}; };
/**
* @classdesc
* Events emitted by {@link ol.Collection} instances are instances of this
* type.
*
* @constructor
* @extends {ol.events.Event}
* @implements {oli.CollectionEvent}
* @param {ol.CollectionEventType} type Type.
* @param {*=} opt_element Element.
*/
export const CollectionEvent = function(type, opt_element) {
Event.call(this, type);
/**
* The element that is added to or removed from the collection.
* @type {*}
* @api
*/
this.element = opt_element;
};
inherits(CollectionEvent, Event);
/** /**
* @typedef {{unique: (boolean|undefined)}} * @typedef {{unique: (boolean|undefined)}}
*/ */
@@ -33,7 +60,7 @@ export let CollectionOptions;
* *
* @constructor * @constructor
* @extends {ol.Object} * @extends {ol.Object}
* @fires ol.Collection.Event * @fires ol.CollectionEvent
* @param {Array.<T>=} opt_array Array. * @param {Array.<T>=} opt_array Array.
* @param {CollectionOptions=} opt_options Collection options. * @param {CollectionOptions=} opt_options Collection options.
* @param {boolean|undefined} opt_options.unique Disallow the same item from * @param {boolean|undefined} opt_options.unique Disallow the same item from
@@ -162,7 +189,7 @@ Collection.prototype.insertAt = function(index, elem) {
this.array_.splice(index, 0, elem); this.array_.splice(index, 0, elem);
this.updateLength_(); this.updateLength_();
this.dispatchEvent( this.dispatchEvent(
new Collection.Event(CollectionEventType.ADD, elem)); new CollectionEvent(CollectionEventType.ADD, elem));
}; };
@@ -222,7 +249,7 @@ Collection.prototype.removeAt = function(index) {
const prev = this.array_[index]; const prev = this.array_[index];
this.array_.splice(index, 1); this.array_.splice(index, 1);
this.updateLength_(); this.updateLength_();
this.dispatchEvent(new Collection.Event(CollectionEventType.REMOVE, prev)); this.dispatchEvent(new CollectionEvent(CollectionEventType.REMOVE, prev));
return prev; return prev;
}; };
@@ -242,9 +269,9 @@ Collection.prototype.setAt = function(index, elem) {
const prev = this.array_[index]; const prev = this.array_[index];
this.array_[index] = elem; this.array_[index] = elem;
this.dispatchEvent( this.dispatchEvent(
new Collection.Event(CollectionEventType.REMOVE, prev)); new CollectionEvent(CollectionEventType.REMOVE, prev));
this.dispatchEvent( this.dispatchEvent(
new Collection.Event(CollectionEventType.ADD, elem)); new CollectionEvent(CollectionEventType.ADD, elem));
} else { } else {
let j; let j;
for (j = n; j < index; ++j) { for (j = n; j < index; ++j) {
@@ -276,29 +303,4 @@ Collection.prototype.assertUnique_ = function(elem, opt_except) {
} }
}; };
/**
* @classdesc
* Events emitted by {@link ol.Collection} instances are instances of this
* type.
*
* @constructor
* @extends {ol.events.Event}
* @implements {oli.Collection.Event}
* @param {ol.CollectionEventType} type Type.
* @param {*=} opt_element Element.
*/
Collection.Event = function(type, opt_element) {
Event.call(this, type);
/**
* The element that is added to or removed from the collection.
* @type {*}
* @api
*/
this.element = opt_element;
};
inherits(Collection.Event, Event);
export default Collection; export default Collection;
+2 -2
View File
@@ -8,13 +8,13 @@
export default { export default {
/** /**
* Triggered when an item is added to the collection. * Triggered when an item is added to the collection.
* @event ol.Collection.Event#add * @event ol.CollectionEvent#add
* @api * @api
*/ */
ADD: 'add', ADD: 'add',
/** /**
* Triggered when an item is removed from the collection. * Triggered when an item is removed from the collection.
* @event ol.Collection.Event#remove * @event ol.CollectionEvent#remove
* @api * @api
*/ */
REMOVE: 'remove' REMOVE: 'remove'
+8 -9
View File
@@ -18,7 +18,7 @@ import ViewHint from './ViewHint.js';
import {assert} from './asserts.js'; import {assert} from './asserts.js';
import {removeNode} from './dom.js'; import {removeNode} from './dom.js';
import {listen, unlistenByKey, unlisten} from './events.js'; import {listen, unlistenByKey, unlisten} from './events.js';
import Event from './events/Event.js'; import {stopPropagation} from './events/Event.js';
import EventType from './events/EventType.js'; import EventType from './events/EventType.js';
import {createEmpty, clone, createOrUpdateEmpty, equals, getForViewAndSize, isEmpty} from './extent.js'; import {createEmpty, clone, createOrUpdateEmpty, equals, getForViewAndSize, isEmpty} from './extent.js';
import {TRUE} from './functions.js'; import {TRUE} from './functions.js';
@@ -248,8 +248,7 @@ const PluggableMap = function(options) {
EventType.WHEEL EventType.WHEEL
]; ];
for (let i = 0, ii = overlayEvents.length; i < ii; ++i) { for (let i = 0, ii = overlayEvents.length; i < ii; ++i) {
listen(this.overlayContainerStopEvent_, overlayEvents[i], listen(this.overlayContainerStopEvent_, overlayEvents[i], stopPropagation);
Event.stopPropagation);
} }
this.viewport_.appendChild(this.overlayContainerStopEvent_); this.viewport_.appendChild(this.overlayContainerStopEvent_);
@@ -371,7 +370,7 @@ const PluggableMap = function(options) {
listen(this.controls, CollectionEventType.ADD, listen(this.controls, CollectionEventType.ADD,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
event.element.setMap(this); event.element.setMap(this);
@@ -379,7 +378,7 @@ const PluggableMap = function(options) {
listen(this.controls, CollectionEventType.REMOVE, listen(this.controls, CollectionEventType.REMOVE,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
event.element.setMap(null); event.element.setMap(null);
@@ -396,7 +395,7 @@ const PluggableMap = function(options) {
listen(this.interactions, CollectionEventType.ADD, listen(this.interactions, CollectionEventType.ADD,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
event.element.setMap(this); event.element.setMap(this);
@@ -404,7 +403,7 @@ const PluggableMap = function(options) {
listen(this.interactions, CollectionEventType.REMOVE, listen(this.interactions, CollectionEventType.REMOVE,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
event.element.setMap(null); event.element.setMap(null);
@@ -414,7 +413,7 @@ const PluggableMap = function(options) {
listen(this.overlays_, CollectionEventType.ADD, listen(this.overlays_, CollectionEventType.ADD,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element)); this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element));
@@ -422,7 +421,7 @@ const PluggableMap = function(options) {
listen(this.overlays_, CollectionEventType.REMOVE, listen(this.overlays_, CollectionEventType.REMOVE,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
const overlay = /** @type {ol.Overlay} */ (event.element); const overlay = /** @type {ol.Overlay} */ (event.element);
+3 -5
View File
@@ -97,11 +97,9 @@ const Attribution = function(opt_options) {
element.appendChild(this.ulElement_); element.appendChild(this.ulElement_);
element.appendChild(button); element.appendChild(button);
const render = options.render ? options.render : Attribution.render;
Control.call(this, { Control.call(this, {
element: element, element: element,
render: render, render: options.render || render,
target: options.target target: options.target
}); });
@@ -189,9 +187,9 @@ Attribution.prototype.getSourceAttributions_ = function(frameState) {
* @this {ol.control.Attribution} * @this {ol.control.Attribution}
* @api * @api
*/ */
Attribution.render = function(mapEvent) { export function render(mapEvent) {
this.updateElement_(mapEvent.frameState); this.updateElement_(mapEvent.frameState);
}; }
/** /**
+19 -19
View File
@@ -80,7 +80,7 @@ const FullScreen = function(opt_options) {
const tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen'; const tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
const button = document.createElement('button'); const button = document.createElement('button');
button.className = this.cssClassName_ + '-' + FullScreen.isFullScreen(); button.className = this.cssClassName_ + '-' + isFullScreen();
button.setAttribute('type', 'button'); button.setAttribute('type', 'button');
button.title = tipLabel; button.title = tipLabel;
button.appendChild(this.labelNode_); button.appendChild(this.labelNode_);
@@ -90,7 +90,7 @@ const FullScreen = function(opt_options) {
const cssClasses = this.cssClassName_ + ' ' + CLASS_UNSELECTABLE + const cssClasses = this.cssClassName_ + ' ' + CLASS_UNSELECTABLE +
' ' + CLASS_CONTROL + ' ' + ' ' + CLASS_CONTROL + ' ' +
(!FullScreen.isFullScreenSupported() ? CLASS_UNSUPPORTED : ''); (!isFullScreenSupported() ? CLASS_UNSUPPORTED : '');
const element = document.createElement('div'); const element = document.createElement('div');
element.className = cssClasses; element.className = cssClasses;
element.appendChild(button); element.appendChild(button);
@@ -131,15 +131,15 @@ FullScreen.prototype.handleClick_ = function(event) {
* @private * @private
*/ */
FullScreen.prototype.handleFullScreen_ = function() { FullScreen.prototype.handleFullScreen_ = function() {
if (!FullScreen.isFullScreenSupported()) { if (!isFullScreenSupported()) {
return; return;
} }
const map = this.getMap(); const map = this.getMap();
if (!map) { if (!map) {
return; return;
} }
if (FullScreen.isFullScreen()) { if (isFullScreen()) {
FullScreen.exitFullScreen(); exitFullScreen();
} else { } else {
let element; let element;
if (this.source_) { if (this.source_) {
@@ -150,10 +150,10 @@ FullScreen.prototype.handleFullScreen_ = function() {
element = map.getTargetElement(); element = map.getTargetElement();
} }
if (this.keys_) { if (this.keys_) {
FullScreen.requestFullScreenWithKeys(element); requestFullScreenWithKeys(element);
} else { } else {
FullScreen.requestFullScreen(element); requestFullScreen(element);
} }
} }
}; };
@@ -165,7 +165,7 @@ FullScreen.prototype.handleFullScreen_ = function() {
FullScreen.prototype.handleFullScreenChange_ = function() { FullScreen.prototype.handleFullScreenChange_ = function() {
const button = this.element.firstElementChild; const button = this.element.firstElementChild;
const map = this.getMap(); const map = this.getMap();
if (FullScreen.isFullScreen()) { if (isFullScreen()) {
button.className = this.cssClassName_ + '-true'; button.className = this.cssClassName_ + '-true';
replaceNode(this.labelActiveNode_, this.labelNode_); replaceNode(this.labelActiveNode_, this.labelNode_);
} else { } else {
@@ -195,7 +195,7 @@ FullScreen.prototype.setMap = function(map) {
/** /**
* @return {boolean} Fullscreen is supported by the current platform. * @return {boolean} Fullscreen is supported by the current platform.
*/ */
FullScreen.isFullScreenSupported = function() { function isFullScreenSupported() {
const body = document.body; const body = document.body;
return !!( return !!(
body.webkitRequestFullscreen || body.webkitRequestFullscreen ||
@@ -203,23 +203,23 @@ FullScreen.isFullScreenSupported = function() {
(body.msRequestFullscreen && document.msFullscreenEnabled) || (body.msRequestFullscreen && document.msFullscreenEnabled) ||
(body.requestFullscreen && document.fullscreenEnabled) (body.requestFullscreen && document.fullscreenEnabled)
); );
}; }
/** /**
* @return {boolean} Element is currently in fullscreen. * @return {boolean} Element is currently in fullscreen.
*/ */
FullScreen.isFullScreen = function() { function isFullScreen() {
return !!( return !!(
document.webkitIsFullScreen || document.mozFullScreen || document.webkitIsFullScreen || document.mozFullScreen ||
document.msFullscreenElement || document.fullscreenElement document.msFullscreenElement || document.fullscreenElement
); );
}; }
/** /**
* Request to fullscreen an element. * Request to fullscreen an element.
* @param {Node} element Element to request fullscreen * @param {Node} element Element to request fullscreen
*/ */
FullScreen.requestFullScreen = function(element) { function requestFullScreen(element) {
if (element.requestFullscreen) { if (element.requestFullscreen) {
element.requestFullscreen(); element.requestFullscreen();
} else if (element.msRequestFullscreen) { } else if (element.msRequestFullscreen) {
@@ -229,26 +229,26 @@ FullScreen.requestFullScreen = function(element) {
} else if (element.webkitRequestFullscreen) { } else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen(); element.webkitRequestFullscreen();
} }
}; }
/** /**
* Request to fullscreen an element with keyboard input. * Request to fullscreen an element with keyboard input.
* @param {Node} element Element to request fullscreen * @param {Node} element Element to request fullscreen
*/ */
FullScreen.requestFullScreenWithKeys = function(element) { function requestFullScreenWithKeys(element) {
if (element.mozRequestFullScreenWithKeys) { if (element.mozRequestFullScreenWithKeys) {
element.mozRequestFullScreenWithKeys(); element.mozRequestFullScreenWithKeys();
} else if (element.webkitRequestFullscreen) { } else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
} else { } else {
FullScreen.requestFullScreen(element); requestFullScreen(element);
} }
}; }
/** /**
* Exit fullscreen. * Exit fullscreen.
*/ */
FullScreen.exitFullScreen = function() { function exitFullScreen() {
if (document.exitFullscreen) { if (document.exitFullscreen) {
document.exitFullscreen(); document.exitFullscreen();
} else if (document.msExitFullscreen) { } else if (document.msExitFullscreen) {
@@ -258,6 +258,6 @@ FullScreen.exitFullScreen = function() {
} else if (document.webkitExitFullscreen) { } else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen(); document.webkitExitFullscreen();
} }
}; }
export default FullScreen; export default FullScreen;
+3 -6
View File
@@ -41,12 +41,9 @@ const MousePosition = function(opt_options) {
const element = document.createElement('DIV'); const element = document.createElement('DIV');
element.className = options.className !== undefined ? options.className : 'ol-mouse-position'; element.className = options.className !== undefined ? options.className : 'ol-mouse-position';
const render = options.render ?
options.render : MousePosition.render;
Control.call(this, { Control.call(this, {
element: element, element: element,
render: render, render: options.render || render,
target: options.target target: options.target
}); });
@@ -102,7 +99,7 @@ inherits(MousePosition, Control);
* @this {ol.control.MousePosition} * @this {ol.control.MousePosition}
* @api * @api
*/ */
MousePosition.render = function(mapEvent) { export function render(mapEvent) {
const frameState = mapEvent.frameState; const frameState = mapEvent.frameState;
if (!frameState) { if (!frameState) {
this.mapProjection_ = null; this.mapProjection_ = null;
@@ -113,7 +110,7 @@ MousePosition.render = function(mapEvent) {
} }
} }
this.updateHTML_(this.lastMouseMovePixel_); this.updateHTML_(this.lastMouseMovePixel_);
}; }
/** /**
+3 -5
View File
@@ -157,11 +157,9 @@ const OverviewMap = function(opt_options) {
element.appendChild(this.ovmapDiv_); element.appendChild(this.ovmapDiv_);
element.appendChild(button); element.appendChild(button);
const render = options.render ? options.render : OverviewMap.render;
Control.call(this, { Control.call(this, {
element: element, element: element,
render: render, render: options.render || render,
target: options.target target: options.target
}); });
@@ -306,10 +304,10 @@ OverviewMap.prototype.handleRotationChanged_ = function() {
* @this {ol.control.OverviewMap} * @this {ol.control.OverviewMap}
* @api * @api
*/ */
OverviewMap.render = function(mapEvent) { export function render(mapEvent) {
this.validateExtent_(); this.validateExtent_();
this.updateBox_(); this.updateBox_();
}; }
/** /**
+4 -5
View File
@@ -59,13 +59,11 @@ const Rotate = function(opt_options) {
element.className = cssClasses; element.className = cssClasses;
element.appendChild(button); element.appendChild(button);
const render = options.render ? options.render : Rotate.render;
this.callResetNorth_ = options.resetNorth ? options.resetNorth : undefined; this.callResetNorth_ = options.resetNorth ? options.resetNorth : undefined;
Control.call(this, { Control.call(this, {
element: element, element: element,
render: render, render: options.render || render,
target: options.target target: options.target
}); });
@@ -141,7 +139,7 @@ Rotate.prototype.resetNorth_ = function() {
* @this {ol.control.Rotate} * @this {ol.control.Rotate}
* @api * @api
*/ */
Rotate.render = function(mapEvent) { export function render(mapEvent) {
const frameState = mapEvent.frameState; const frameState = mapEvent.frameState;
if (!frameState) { if (!frameState) {
return; return;
@@ -162,5 +160,6 @@ Rotate.render = function(mapEvent) {
this.label_.style.transform = transform; this.label_.style.transform = transform;
} }
this.rotation_ = rotation; this.rotation_ = rotation;
}; }
export default Rotate; export default Rotate;
+3 -5
View File
@@ -91,11 +91,9 @@ const ScaleLine = function(opt_options) {
*/ */
this.renderedHTML_ = ''; this.renderedHTML_ = '';
const render = options.render ? options.render : ScaleLine.render;
Control.call(this, { Control.call(this, {
element: this.element_, element: this.element_,
render: render, render: options.render || render,
target: options.target target: options.target
}); });
@@ -129,7 +127,7 @@ ScaleLine.prototype.getUnits = function() {
* @this {ol.control.ScaleLine} * @this {ol.control.ScaleLine}
* @api * @api
*/ */
ScaleLine.render = function(mapEvent) { export function render(mapEvent) {
const frameState = mapEvent.frameState; const frameState = mapEvent.frameState;
if (!frameState) { if (!frameState) {
this.viewState_ = null; this.viewState_ = null;
@@ -137,7 +135,7 @@ ScaleLine.render = function(mapEvent) {
this.viewState_ = frameState.viewState; this.viewState_ = frameState.viewState;
} }
this.updateElement_(); this.updateElement_();
}; }
/** /**
+6 -10
View File
@@ -7,7 +7,7 @@ import Control from '../control/Control.js';
import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js'; import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
import {easeOut} from '../easing.js'; import {easeOut} from '../easing.js';
import {listen} from '../events.js'; import {listen} from '../events.js';
import Event from '../events/Event.js'; import {stopPropagation} from '../events/Event.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {clamp} from '../math.js'; import {clamp} from '../math.js';
import PointerEventType from '../pointer/EventType.js'; import PointerEventType from '../pointer/EventType.js';
@@ -130,16 +130,12 @@ const ZoomSlider = function(opt_options) {
listen(this.dragger_, PointerEventType.POINTERUP, listen(this.dragger_, PointerEventType.POINTERUP,
this.handleDraggerEnd_, this); this.handleDraggerEnd_, this);
listen(containerElement, EventType.CLICK, listen(containerElement, EventType.CLICK, this.handleContainerClick_, this);
this.handleContainerClick_, this); listen(thumbElement, EventType.CLICK, stopPropagation);
listen(thumbElement, EventType.CLICK,
Event.stopPropagation);
const render = options.render ? options.render : ZoomSlider.render;
Control.call(this, { Control.call(this, {
element: containerElement, element: containerElement,
render: render render: options.render || render
}); });
}; };
@@ -206,7 +202,7 @@ ZoomSlider.prototype.initSlider_ = function() {
* @this {ol.control.ZoomSlider} * @this {ol.control.ZoomSlider}
* @api * @api
*/ */
ZoomSlider.render = function(mapEvent) { export function render(mapEvent) {
if (!mapEvent.frameState) { if (!mapEvent.frameState) {
return; return;
} }
@@ -218,7 +214,7 @@ ZoomSlider.render = function(mapEvent) {
this.currentResolution_ = res; this.currentResolution_ = res;
this.setThumbPosition_(res); this.setThumbPosition_(res);
} }
}; }
/** /**
+5 -4
View File
@@ -61,15 +61,16 @@ Event.prototype.preventDefault =
/** /**
* @param {Event|ol.events.Event} evt Event * @param {Event|ol.events.Event} evt Event
*/ */
Event.stopPropagation = function(evt) { export function stopPropagation(evt) {
evt.stopPropagation(); evt.stopPropagation();
}; }
/** /**
* @param {Event|ol.events.Event} evt Event * @param {Event|ol.events.Event} evt Event
*/ */
Event.preventDefault = function(evt) { export function preventDefault(evt) {
evt.preventDefault(); evt.preventDefault();
}; }
export default Event; export default Event;
+2 -2
View File
@@ -355,7 +355,7 @@ Modify.prototype.handleSourceRemove_ = function(event) {
/** /**
* @param {ol.Collection.Event} evt Event. * @param {ol.CollectionEvent} evt Event.
* @private * @private
*/ */
Modify.prototype.handleFeatureAdd_ = function(evt) { Modify.prototype.handleFeatureAdd_ = function(evt) {
@@ -377,7 +377,7 @@ Modify.prototype.handleFeatureChange_ = function(evt) {
/** /**
* @param {ol.Collection.Event} evt Event. * @param {ol.CollectionEvent} evt Event.
* @private * @private
*/ */
Modify.prototype.handleFeatureRemove_ = function(evt) { Modify.prototype.handleFeatureRemove_ = function(evt) {
+2 -2
View File
@@ -349,7 +349,7 @@ Select.getDefaultStyleFunction = function() {
/** /**
* @param {ol.Collection.Event} evt Event. * @param {ol.CollectionEvent} evt Event.
* @private * @private
*/ */
Select.prototype.addFeature_ = function(evt) { Select.prototype.addFeature_ = function(evt) {
@@ -361,7 +361,7 @@ Select.prototype.addFeature_ = function(evt) {
/** /**
* @param {ol.Collection.Event} evt Event. * @param {ol.CollectionEvent} evt Event.
* @private * @private
*/ */
Select.prototype.removeFeature_ = function(evt) { Select.prototype.removeFeature_ = function(evt) {
+5 -5
View File
@@ -2,7 +2,7 @@
* @module ol/interaction/Snap * @module ol/interaction/Snap
*/ */
import {getUid, inherits} from '../index.js'; import {getUid, inherits} from '../index.js';
import Collection from '../Collection.js'; import {CollectionEvent} from '../Collection.js';
import CollectionEventType from '../CollectionEventType.js'; import CollectionEventType from '../CollectionEventType.js';
import {distance as coordinateDistance, squaredDistance as squaredCoordinateDistance, closestOnCircle, closestOnSegment, squaredDistanceToSegment} from '../coordinate.js'; import {distance as coordinateDistance, squaredDistance as squaredCoordinateDistance, closestOnCircle, closestOnSegment, squaredDistanceToSegment} from '../coordinate.js';
import {listen, unlistenByKey} from '../events.js'; import {listen, unlistenByKey} from '../events.js';
@@ -214,14 +214,14 @@ Snap.prototype.getFeatures_ = function() {
/** /**
* @param {ol.source.Vector.Event|ol.Collection.Event} evt Event. * @param {ol.source.Vector.Event|ol.CollectionEvent} evt Event.
* @private * @private
*/ */
Snap.prototype.handleFeatureAdd_ = function(evt) { Snap.prototype.handleFeatureAdd_ = function(evt) {
let feature; let feature;
if (evt instanceof VectorSource.Event) { if (evt instanceof VectorSource.Event) {
feature = evt.feature; feature = evt.feature;
} else if (evt instanceof Collection.Event) { } else if (evt instanceof CollectionEvent) {
feature = evt.element; feature = evt.element;
} }
this.addFeature(/** @type {ol.Feature} */ (feature)); this.addFeature(/** @type {ol.Feature} */ (feature));
@@ -229,14 +229,14 @@ Snap.prototype.handleFeatureAdd_ = function(evt) {
/** /**
* @param {ol.source.Vector.Event|ol.Collection.Event} evt Event. * @param {ol.source.Vector.Event|ol.CollectionEvent} evt Event.
* @private * @private
*/ */
Snap.prototype.handleFeatureRemove_ = function(evt) { Snap.prototype.handleFeatureRemove_ = function(evt) {
let feature; let feature;
if (evt instanceof VectorSource.Event) { if (evt instanceof VectorSource.Event) {
feature = evt.feature; feature = evt.feature;
} else if (evt instanceof Collection.Event) { } else if (evt instanceof CollectionEvent) {
feature = evt.element; feature = evt.element;
} }
this.removeFeature(/** @type {ol.Feature} */ (feature)); this.removeFeature(/** @type {ol.Feature} */ (feature));
+2 -2
View File
@@ -121,7 +121,7 @@ LayerGroup.prototype.handleLayersChanged_ = function(event) {
/** /**
* @param {ol.Collection.Event} collectionEvent Collection event. * @param {ol.CollectionEvent} collectionEvent CollectionEvent.
* @private * @private
*/ */
LayerGroup.prototype.handleLayersAdd_ = function(collectionEvent) { LayerGroup.prototype.handleLayersAdd_ = function(collectionEvent) {
@@ -136,7 +136,7 @@ LayerGroup.prototype.handleLayersAdd_ = function(collectionEvent) {
/** /**
* @param {ol.Collection.Event} collectionEvent Collection event. * @param {ol.CollectionEvent} collectionEvent CollectionEvent.
* @private * @private
*/ */
LayerGroup.prototype.handleLayersRemove_ = function(collectionEvent) { LayerGroup.prototype.handleLayersRemove_ = function(collectionEvent) {
+3 -5
View File
@@ -1,6 +1,6 @@
import Map from '../../../../src/ol/Map.js'; import Map from '../../../../src/ol/Map.js';
import View from '../../../../src/ol/View.js'; import View from '../../../../src/ol/View.js';
import ScaleLine from '../../../../src/ol/control/ScaleLine.js'; import ScaleLine, {render} from '../../../../src/ol/control/ScaleLine.js';
import {fromLonLat} from '../../../../src/ol/proj.js'; import {fromLonLat} from '../../../../src/ol/proj.js';
import Projection from '../../../../src/ol/proj/Projection.js'; import Projection from '../../../../src/ol/proj/Projection.js';
@@ -67,12 +67,10 @@ describe('ol.control.ScaleLine', function() {
describe('render', function() { describe('render', function() {
it('defaults to `ol.control.ScaleLine.render`', function() { it('defaults to `ol.control.ScaleLine.render`', function() {
const ctrl = new ScaleLine(); const ctrl = new ScaleLine();
expect(ctrl.render).to.be(ScaleLine.render); expect(ctrl.render).to.be(render);
}); });
it('can be configured', function() { it('can be configured', function() {
const myRender = function() { const myRender = function() {};
};
const ctrl = new ScaleLine({ const ctrl = new ScaleLine({
render: myRender render: myRender
}); });
+3 -3
View File
@@ -1,4 +1,4 @@
import Event from '../../../../src/ol/events/Event.js'; import Event, {preventDefault, stopPropagation} from '../../../../src/ol/events/Event.js';
describe('ol.events.Event', function() { describe('ol.events.Event', function() {
@@ -30,7 +30,7 @@ describe('ol.events.Event', function() {
const event = { const event = {
preventDefault: sinon.spy() preventDefault: sinon.spy()
}; };
Event.preventDefault(event); preventDefault(event);
expect(event.preventDefault.called).to.be(true); expect(event.preventDefault.called).to.be(true);
}); });
}); });
@@ -40,7 +40,7 @@ describe('ol.events.Event', function() {
const event = { const event = {
stopPropagation: sinon.spy() stopPropagation: sinon.spy()
}; };
Event.stopPropagation(event); stopPropagation(event);
expect(event.stopPropagation.called).to.be(true); expect(event.stopPropagation.called).to.be(true);
}); });
}); });