Merge pull request #13447 from MoonE/fullscreen-uninitialized

Initialize variable before use in FullScreen control
This commit is contained in:
MoonE
2022-03-05 22:19:56 +01:00
committed by GitHub
+34 -34
View File
@@ -105,6 +105,29 @@ class FullScreen extends Control {
*/ */
this.un; this.un;
/**
* @private
* @type {boolean}
*/
this.keys_ = options.keys !== undefined ? options.keys : false;
/**
* @private
* @type {HTMLElement|string|undefined}
*/
this.source_ = options.source;
/**
* @type {boolean}
* @private
*/
this.isInFullscreen_ = false;
/**
* @private
*/
this.boundHandleMapTargetChange_ = this.handleMapTargetChange_.bind(this);
/** /**
* @private * @private
* @type {string} * @type {string}
@@ -157,49 +180,25 @@ class FullScreen extends Control {
? document.createTextNode(labelActive) ? document.createTextNode(labelActive)
: labelActive; : labelActive;
const tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
/** /**
* @private * @private
* @type {HTMLElement} * @type {HTMLElement}
*/ */
this.button_ = document.createElement('button'); this.button_ = document.createElement('button');
const tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
this.button_.setAttribute('type', 'button');
this.setClassName_(this.button_, this.isInFullscreen_);
this.button_.title = tipLabel; this.button_.title = tipLabel;
this.button_.setAttribute('type', 'button');
this.button_.appendChild(this.labelNode_); this.button_.appendChild(this.labelNode_);
this.button_.addEventListener( this.button_.addEventListener(
EventType.CLICK, EventType.CLICK,
this.handleClick_.bind(this), this.handleClick_.bind(this),
false false
); );
this.setClassName_(this.button_, this.isInFullscreen_);
this.element.className = `${this.cssClassName_} ${CLASS_UNSELECTABLE} ${CLASS_CONTROL}`; this.element.className = `${this.cssClassName_} ${CLASS_UNSELECTABLE} ${CLASS_CONTROL}`;
this.element.appendChild(this.button_); this.element.appendChild(this.button_);
/**
* @private
* @type {boolean}
*/
this.keys_ = options.keys !== undefined ? options.keys : false;
/**
* @private
* @type {HTMLElement|string|undefined}
*/
this.source_ = options.source;
/**
* @type {boolean}
* @private
*/
this.isInFullscreen_ = false;
/**
* @private
*/
this.boundHandleMapTargetChange_ = this.handleMapTargetChange_.bind(this);
} }
/** /**
@@ -272,12 +271,13 @@ class FullScreen extends Control {
* @private * @private
*/ */
setClassName_(element, fullscreen) { setClassName_(element, fullscreen) {
const activeClassName = this.activeClassName_; if (fullscreen) {
const inactiveClassName = this.inactiveClassName_; element.classList.remove(...this.inactiveClassName_);
const nextClassName = fullscreen ? activeClassName : inactiveClassName; element.classList.add(...this.activeClassName_);
element.classList.remove(...activeClassName); } else {
element.classList.remove(...inactiveClassName); element.classList.remove(...this.activeClassName_);
element.classList.add(...nextClassName); element.classList.add(...this.inactiveClassName_);
}
} }
/** /**