Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove opt_ prefix #13972

Merged
merged 1 commit into from Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/ol/Collection.js
Expand Up @@ -76,10 +76,10 @@ export class CollectionEvent extends Event {
*/
class Collection extends BaseObject {
/**
* @param {Array<T>} [opt_array] Array.
* @param {Options} [opt_options] Collection options.
* @param {Array<T>} [array] Array.
* @param {Options} [options] Collection options.
*/
constructor(opt_array, opt_options) {
constructor(array, options) {
super();

/***
Expand All @@ -97,7 +97,7 @@ class Collection extends BaseObject {
*/
this.un;

const options = opt_options || {};
options = options || {};

/**
* @private
Expand All @@ -109,7 +109,7 @@ class Collection extends BaseObject {
* @private
* @type {!Array<T>}
*/
this.array_ = opt_array ? opt_array : [];
this.array_ = array ? array : [];

if (this.unique_) {
for (let i = 0, ii = this.array_.length; i < ii; ++i) {
Expand Down Expand Up @@ -315,11 +315,11 @@ class Collection extends BaseObject {
/**
* @private
* @param {T} elem Element.
* @param {number} [opt_except] Optional index to ignore.
* @param {number} [except] Optional index to ignore.
*/
assertUnique_(elem, opt_except) {
assertUnique_(elem, except) {
for (let i = 0, ii = this.array_.length; i < ii; ++i) {
if (this.array_[i] === elem && i !== opt_except) {
if (this.array_[i] === elem && i !== except) {
throw new AssertionError(58);
}
}
Expand Down
22 changes: 10 additions & 12 deletions src/ol/Feature.js
Expand Up @@ -74,12 +74,12 @@ import {listen, unlistenByKey} from './events.js';
*/
class Feature extends BaseObject {
/**
* @param {Geometry|ObjectWithGeometry<Geometry>} [opt_geometryOrProperties]
* @param {Geometry|ObjectWithGeometry<Geometry>} [geometryOrProperties]
* You may pass a Geometry object directly, or an object literal containing
* properties. If you pass an object literal, you may include a Geometry
* associated with a `geometry` key.
*/
constructor(opt_geometryOrProperties) {
constructor(geometryOrProperties) {
super();

/***
Expand Down Expand Up @@ -130,17 +130,17 @@ class Feature extends BaseObject {

this.addChangeListener(this.geometryName_, this.handleGeometryChanged_);

if (opt_geometryOrProperties) {
if (geometryOrProperties) {
if (
typeof (
/** @type {?} */ (opt_geometryOrProperties).getSimplifiedGeometry
/** @type {?} */ (geometryOrProperties).getSimplifiedGeometry
) === 'function'
) {
const geometry = /** @type {Geometry} */ (opt_geometryOrProperties);
const geometry = /** @type {Geometry} */ (geometryOrProperties);
this.setGeometry(geometry);
} else {
/** @type {Object<string, *>} */
const properties = opt_geometryOrProperties;
const properties = geometryOrProperties;
this.setProperties(properties);
}
}
Expand Down Expand Up @@ -265,15 +265,13 @@ class Feature extends BaseObject {
* single style object, an array of styles, or a function that takes a
* resolution and returns an array of styles. To unset the feature style, call
* `setStyle()` without arguments or a falsey value.
* @param {import("./style/Style.js").StyleLike} [opt_style] Style for this feature.
* @param {import("./style/Style.js").StyleLike} [style] Style for this feature.
* @api
* @fires module:ol/events/Event~BaseEvent#event:change
*/
setStyle(opt_style) {
this.style_ = opt_style;
this.styleFunction_ = !opt_style
? undefined
: createStyleFunction(opt_style);
setStyle(style) {
this.style_ = style;
this.styleFunction_ = !style ? undefined : createStyleFunction(style);
this.changed();
}

Expand Down
6 changes: 3 additions & 3 deletions src/ol/Geolocation.js
Expand Up @@ -101,9 +101,9 @@ class GeolocationError extends BaseEvent {
*/
class Geolocation extends BaseObject {
/**
* @param {Options} [opt_options] Options.
* @param {Options} [options] Options.
*/
constructor(opt_options) {
constructor(options) {
super();

/***
Expand All @@ -121,7 +121,7 @@ class Geolocation extends BaseObject {
*/
this.un;

const options = opt_options || {};
options = options || {};

/**
* The unprojected (EPSG:4326) device position.
Expand Down
9 changes: 4 additions & 5 deletions src/ol/ImageCanvas.js
Expand Up @@ -19,12 +19,11 @@ class ImageCanvas extends ImageBase {
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {HTMLCanvasElement} canvas Canvas.
* @param {Loader} [opt_loader] Optional loader function to
* @param {Loader} [loader] Optional loader function to
* support asynchronous canvas drawing.
*/
constructor(extent, resolution, pixelRatio, canvas, opt_loader) {
const state =
opt_loader !== undefined ? ImageState.IDLE : ImageState.LOADED;
constructor(extent, resolution, pixelRatio, canvas, loader) {
const state = loader !== undefined ? ImageState.IDLE : ImageState.LOADED;

super(extent, resolution, pixelRatio, state);

Expand All @@ -33,7 +32,7 @@ class ImageCanvas extends ImageBase {
* @type {?Loader}
* @private
*/
this.loader_ = opt_loader !== undefined ? opt_loader : null;
this.loader_ = loader !== undefined ? loader : null;

/**
* @private
Expand Down
13 changes: 3 additions & 10 deletions src/ol/ImageTile.js
Expand Up @@ -13,17 +13,10 @@ class ImageTile extends Tile {
* @param {string} src Image source URI.
* @param {?string} crossOrigin Cross origin.
* @param {import("./Tile.js").LoadFunction} tileLoadFunction Tile load function.
* @param {import("./Tile.js").Options} [opt_options] Tile options.
* @param {import("./Tile.js").Options} [options] Tile options.
*/
constructor(
tileCoord,
state,
src,
crossOrigin,
tileLoadFunction,
opt_options
) {
super(tileCoord, state, opt_options);
constructor(tileCoord, state, src, crossOrigin, tileLoadFunction, options) {
super(tileCoord, state, options);

/**
* @private
Expand Down
46 changes: 23 additions & 23 deletions src/ol/Map.js
Expand Up @@ -234,12 +234,12 @@ function setLayerMapProperty(layer, map) {
*/
class Map extends BaseObject {
/**
* @param {MapOptions} [opt_options] Map options.
* @param {MapOptions} [options] Map options.
*/
constructor(opt_options) {
constructor(options) {
super();

const options = opt_options || {};
options = options || {};

/***
* @type {MapEventHandler<import("./events").EventsKey>}
Expand Down Expand Up @@ -652,7 +652,7 @@ class Map extends BaseObject {
/**
* Detect features that intersect a pixel on the viewport, and execute a
* callback with each intersecting feature. Layers included in the detection can
* be configured through the `layerFilter` option in `opt_options`.
* be configured through the `layerFilter` option in `options`.
* @param {import("./pixel.js").Pixel} pixel Pixel.
* @param {function(import("./Feature.js").FeatureLike, import("./layer/Layer.js").default<import("./source/Source").default>, import("./geom/SimpleGeometry.js").default): T} callback Feature callback. The callback will be
* called with two arguments. The first argument is one
Expand All @@ -661,23 +661,23 @@ class Map extends BaseObject {
* the {@link module:ol/layer/Layer~Layer layer} of the feature and will be null for
* unmanaged layers. To stop detection, callback functions can return a
* truthy value.
* @param {AtPixelOptions} [opt_options] Optional options.
* @param {AtPixelOptions} [options] Optional options.
* @return {T|undefined} Callback result, i.e. the return value of last
* callback execution, or the first truthy callback return value.
* @template T
* @api
*/
forEachFeatureAtPixel(pixel, callback, opt_options) {
forEachFeatureAtPixel(pixel, callback, options) {
if (!this.frameState_ || !this.renderer_) {
return;
}
const coordinate = this.getCoordinateFromPixelInternal(pixel);
opt_options = opt_options !== undefined ? opt_options : {};
options = options !== undefined ? options : {};
const hitTolerance =
opt_options.hitTolerance !== undefined ? opt_options.hitTolerance : 0;
options.hitTolerance !== undefined ? options.hitTolerance : 0;
const layerFilter =
opt_options.layerFilter !== undefined ? opt_options.layerFilter : TRUE;
const checkWrapped = opt_options.checkWrapped !== false;
options.layerFilter !== undefined ? options.layerFilter : TRUE;
const checkWrapped = options.checkWrapped !== false;
return this.renderer_.forEachFeatureAtCoordinate(
coordinate,
this.frameState_,
Expand All @@ -693,19 +693,19 @@ class Map extends BaseObject {
/**
* Get all features that intersect a pixel on the viewport.
* @param {import("./pixel.js").Pixel} pixel Pixel.
* @param {AtPixelOptions} [opt_options] Optional options.
* @param {AtPixelOptions} [options] Optional options.
* @return {Array<import("./Feature.js").FeatureLike>} The detected features or
* an empty array if none were found.
* @api
*/
getFeaturesAtPixel(pixel, opt_options) {
getFeaturesAtPixel(pixel, options) {
const features = [];
this.forEachFeatureAtPixel(
pixel,
function (feature) {
features.push(feature);
},
opt_options
options
);
return features;
}
Expand All @@ -732,23 +732,23 @@ class Map extends BaseObject {

/**
* Detect if features intersect a pixel on the viewport. Layers included in the
* detection can be configured through `opt_layerFilter`.
* detection can be configured through the `layerFilter` option.
* @param {import("./pixel.js").Pixel} pixel Pixel.
* @param {AtPixelOptions} [opt_options] Optional options.
* @param {AtPixelOptions} [options] Optional options.
* @return {boolean} Is there a feature at the given pixel?
* @api
*/
hasFeatureAtPixel(pixel, opt_options) {
hasFeatureAtPixel(pixel, options) {
if (!this.frameState_ || !this.renderer_) {
return false;
}
const coordinate = this.getCoordinateFromPixelInternal(pixel);
opt_options = opt_options !== undefined ? opt_options : {};
options = options !== undefined ? options : {};
const layerFilter =
opt_options.layerFilter !== undefined ? opt_options.layerFilter : TRUE;
options.layerFilter !== undefined ? options.layerFilter : TRUE;
const hitTolerance =
opt_options.hitTolerance !== undefined ? opt_options.hitTolerance : 0;
const checkWrapped = opt_options.checkWrapped !== false;
options.hitTolerance !== undefined ? options.hitTolerance : 0;
const checkWrapped = options.checkWrapped !== false;
return this.renderer_.hasFeatureAtCoordinate(
coordinate,
this.frameState_,
Expand Down Expand Up @@ -1089,10 +1089,10 @@ class Map extends BaseObject {

/**
* @param {UIEvent} browserEvent Browser event.
* @param {string} [opt_type] Type.
* @param {string} [type] Type.
*/
handleBrowserEvent(browserEvent, opt_type) {
const type = opt_type || browserEvent.type;
handleBrowserEvent(browserEvent, type) {
type = type || browserEvent.type;
const mapBrowserEvent = new MapBrowserEvent(type, this, browserEvent);
this.handleMapBrowserEvent(mapBrowserEvent);
}
Expand Down
21 changes: 7 additions & 14 deletions src/ol/MapBrowserEvent.js
Expand Up @@ -14,19 +14,12 @@ class MapBrowserEvent extends MapEvent {
* @param {string} type Event type.
* @param {import("./Map.js").default} map Map.
* @param {EVENT} originalEvent Original event.
* @param {boolean} [opt_dragging] Is the map currently being dragged?
* @param {import("./Map.js").FrameState} [opt_frameState] Frame state.
* @param {Array<PointerEvent>} [opt_activePointers] Active pointers.
* @param {boolean} [dragging] Is the map currently being dragged?
* @param {import("./Map.js").FrameState} [frameState] Frame state.
* @param {Array<PointerEvent>} [activePointers] Active pointers.
*/
constructor(
type,
map,
originalEvent,
opt_dragging,
opt_frameState,
opt_activePointers
) {
super(type, map, opt_frameState);
constructor(type, map, originalEvent, dragging, frameState, activePointers) {
super(type, map, frameState);

/**
* The original browser event.
Expand Down Expand Up @@ -55,12 +48,12 @@ class MapBrowserEvent extends MapEvent {
* @type {boolean}
* @api
*/
this.dragging = opt_dragging !== undefined ? opt_dragging : false;
this.dragging = dragging !== undefined ? dragging : false;

/**
* @type {Array<PointerEvent>|undefined}
*/
this.activePointers = opt_activePointers;
this.activePointers = activePointers;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/ol/MapEvent.js
Expand Up @@ -12,9 +12,9 @@ class MapEvent extends Event {
/**
* @param {string} type Event type.
* @param {import("./Map.js").default} map Map.
* @param {?import("./Map.js").FrameState} [opt_frameState] Frame state.
* @param {?import("./Map.js").FrameState} [frameState] Frame state.
*/
constructor(type, map, opt_frameState) {
constructor(type, map, frameState) {
super(type);

/**
Expand All @@ -29,7 +29,7 @@ class MapEvent extends Event {
* @type {?import("./Map.js").FrameState}
* @api
*/
this.frameState = opt_frameState !== undefined ? opt_frameState : null;
this.frameState = frameState !== undefined ? frameState : null;
}
}

Expand Down