From ae73af819ddf3a89354c31bf29c4fbe19a3f32d3 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 15 Apr 2019 17:10:39 +0800 Subject: [PATCH] [bugfix] Popup: may cause event uncancelable warning (#3150) --- packages/mixins/popup/index.js | 11 ++++++----- packages/rate/index.tsx | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/mixins/popup/index.js b/packages/mixins/popup/index.js index 4519ffcf9..ba917ce59 100644 --- a/packages/mixins/popup/index.js +++ b/packages/mixins/popup/index.js @@ -160,10 +160,10 @@ export const PopupMixin = { } }, - onTouchMove(e) { - this.touchMove(e); + onTouchMove(event) { + this.touchMove(event); const direction = this.deltaY > 0 ? '10' : '01'; - const el = getScrollEventTarget(e.target, this.$el); + const el = getScrollEventTarget(event.target, this.$el); const { scrollHeight, offsetHeight, scrollTop } = el; let status = '11'; @@ -176,12 +176,13 @@ export const PopupMixin = { /* istanbul ignore next */ if ( + event.cancelable && status !== '11' && this.direction === 'vertical' && !(parseInt(status, 2) & parseInt(direction, 2)) ) { - e.preventDefault(); - e.stopPropagation(); + event.preventDefault(); + event.stopPropagation(); } }, diff --git a/packages/rate/index.tsx b/packages/rate/index.tsx index 5257eafb4..b330f8ad6 100644 --- a/packages/rate/index.tsx +++ b/packages/rate/index.tsx @@ -46,7 +46,16 @@ function Rate( slots: DefaultSlots, ctx: RenderContext ) { - const { size, icon, voidIcon, color, voidColor, disabled, disabledColor } = props; + const { + icon, + size, + color, + voidIcon, + readonly, + disabled, + voidColor, + disabledColor + } = props; const list: RateStatus[] = []; for (let i = 1; i <= props.count; i++) { @@ -54,14 +63,14 @@ function Rate( } function onSelect(index: number) { - if (!disabled && !props.readonly) { + if (!disabled && !readonly) { emit(ctx, 'input', index); emit(ctx, 'change', index); } } function onTouchMove(event: TouchEvent) { - if (!document.elementFromPoint || props.readonly || props.disabled) { + if (readonly || disabled || !document.elementFromPoint) { return; }