From 344b105e0efc73bc1e8b774c84d4f3e9fdb850b8 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 26 Jun 2019 14:26:03 +0800 Subject: [PATCH] [improvement] Notify: improve event binding (#3640) --- packages/notify/Notify.tsx | 13 ++----------- packages/notify/index.ts | 9 +++++---- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/notify/Notify.tsx b/packages/notify/Notify.tsx index c6e883d16..05c94c798 100644 --- a/packages/notify/Notify.tsx +++ b/packages/notify/Notify.tsx @@ -1,6 +1,6 @@ import { use } from '../utils'; import { RED, WHITE } from '../utils/color'; -import { emit, inherit } from '../utils/functional'; +import { inherit } from '../utils/functional'; import { PopupMixin } from '../mixins/popup'; import Popup from '../popup'; @@ -38,16 +38,7 @@ function Notify( overlay={false} lockScroll={false} class={[bem(), props.className]} - onInput={(value: boolean) => { - emit(ctx, 'input', value); - }} - onClick={(event: Event) => { - emit(ctx, 'click', event); - }} - onOpened={() => { - emit(ctx, 'opened'); - }} - {...inherit(ctx)} + {...inherit(ctx, true)} > {props.message} diff --git a/packages/notify/index.ts b/packages/notify/index.ts index f30884e10..8a80ccc59 100644 --- a/packages/notify/index.ts +++ b/packages/notify/index.ts @@ -26,6 +26,11 @@ function Notify(options: NotifyOptions) { instance.onClick(event); } }, + close() { + if (instance.onClose) { + instance.onClose(); + } + }, opened() { if (instance.onOpened) { instance.onOpened(); @@ -67,10 +72,6 @@ function defaultOptions(): NotifyOptions { Notify.clear = () => { if (instance) { instance.value = false; - - if (instance.onClose) { - instance.onClose(); - } } };