fix(button): make redispatch method protected

This commit is contained in:
Mikhail Bashkirov 2019-07-12 15:52:28 +02:00
parent 59e456e11f
commit b7eb537d1d

View file

@ -152,17 +152,21 @@ export class LionButton extends DelegateMixin(SlotMixin(LionLitElement)) {
this.__teardownDelegation();
}
/**
* Prevent click on the fake element and cause click on the native button.
*/
__clickDelegationHandler(oldEvent) {
oldEvent.stopPropagation();
_redispatchClickEvent(oldEvent) {
// replacing `MouseEvent` with `oldEvent.constructor` breaks IE
const newEvent = new MouseEvent(oldEvent.type, oldEvent);
this.__enforceHostEventTarget(newEvent);
this.$$slot('_button').dispatchEvent(newEvent);
}
/**
* Prevent click on the fake element and cause click on the native button.
*/
__clickDelegationHandler(e) {
e.stopPropagation();
this._redispatchClickEvent(e);
}
__enforceHostEventTarget(event) {
try {
// this is for IE11 (and works in others), because `Object.defineProperty` does not give any effect there