Remove MousePosition's deprecated undefinedHTML option
Simplify the placeholder option to only accept strings or undefined.
This commit is contained in:
@@ -41,13 +41,11 @@ const COORDINATE_FORMAT = 'coordinateFormat';
|
||||
* callback.
|
||||
* @property {HTMLElement|string} [target] Specify a target if you want the
|
||||
* control to be rendered outside of the map's viewport.
|
||||
* @property {string|boolean} [placeholder] Markup to show when the mouse position is not
|
||||
* available (e.g. when the pointer leaves the map viewport). By default, a non-breaking space
|
||||
* is rendered when the mouse leaves the viewport. To render something else, provide a string
|
||||
* to be used as the text content (e.g. 'no position' or '' for an empty string). Set the placeholder
|
||||
* to `false` to retain the last position when the mouse leaves the viewport. In a future release, this
|
||||
* will be the default behavior.
|
||||
* @property {string} [undefinedHTML=' '] This option is deprecated. Use the `placeholder` option instead.
|
||||
* @property {string} [placeholder] Markup to show when the mouse position is not
|
||||
* available (e.g. when the pointer leaves the map viewport). By default, a non-breaking space is rendered
|
||||
* initially and the last position is retained when the mouse leaves the viewport.
|
||||
* When a string is provided (e.g. `'no position'` or `''` for an empty string) it is used as a
|
||||
* placeholder.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -104,41 +102,16 @@ class MousePosition extends Control {
|
||||
}
|
||||
|
||||
/**
|
||||
* Change this to `false` when removing the deprecated `undefinedHTML` option.
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
let renderOnMouseOut = true;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
let placeholder = ' ';
|
||||
|
||||
if ('undefinedHTML' in options) {
|
||||
// deprecated behavior
|
||||
if (options.undefinedHTML !== undefined) {
|
||||
placeholder = options.undefinedHTML;
|
||||
}
|
||||
renderOnMouseOut = !!placeholder;
|
||||
} else if ('placeholder' in options) {
|
||||
if (options.placeholder === false) {
|
||||
renderOnMouseOut = false;
|
||||
} else {
|
||||
placeholder = String(options.placeholder);
|
||||
}
|
||||
}
|
||||
this.renderOnMouseOut_ = options.placeholder !== undefined;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.placeholder_ = placeholder;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.renderOnMouseOut_ = renderOnMouseOut;
|
||||
this.placeholder_ = this.renderOnMouseOut_ ? options.placeholder : ' ';
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user