Fix custom controls with user-provided element

This commit is contained in:
Andreas Hocevar
2020-05-15 17:50:44 +02:00
parent 455d0beb52
commit e5167f4e12
11 changed files with 43 additions and 24 deletions

View File

@@ -50,11 +50,16 @@ class Control extends BaseObject {
constructor(options) {
super();
const element = options.element;
if (element && !options.target && !element.style.pointerEvents) {
element.style.pointerEvents = 'auto';
}
/**
* @protected
* @type {HTMLElement}
*/
this.element = options.element ? options.element : null;
this.element = element ? element : null;
/**
* @private
@@ -83,17 +88,6 @@ class Control extends BaseObject {
}
}
/**
* Creates the element for this control and sets it on the instance.
* @return {HTMLDivElement} Element for this control.
*/
createElement() {
const element = document.createElement('div');
element.style.pointerEvents = 'auto';
this.element = element;
return element;
}
/**
* Clean up.
*/