@@ -92,7 +92,7 @@ exports[`renders ./components/alert/demo/icon.md correctly 1`] = `
exports[`renders ./components/alert/demo/smooth-closed.md correctly 1`] = `
-
diff --git a/components/alert/__tests__/index.test.js b/components/alert/__tests__/index.test.js
index bb04ba8ce..e9e72d43f 100644
--- a/components/alert/__tests__/index.test.js
+++ b/components/alert/__tests__/index.test.js
@@ -28,10 +28,10 @@ describe('Alert', () => {
},
});
wrapper.find('.ant-alert-close-icon').trigger('click');
- expect(onClose).toBeCalled();
+ expect(onClose).toHaveBeenCalled();
jest.runAllTimers();
wrapper.vm.$refs.alert.animationEnd();
- expect(afterClose).toBeCalled();
+ expect(afterClose).toHaveBeenCalled();
});
describe('data and aria props', () => {
diff --git a/components/alert/index.en-US.md b/components/alert/index.en-US.md
index ac22fce3c..182f31f9b 100644
--- a/components/alert/index.en-US.md
+++ b/components/alert/index.en-US.md
@@ -1,19 +1,19 @@
## API
-| Property | Description | Type | Default |
-| --- | --- | --- | --- |
-| afterClose | Called when close animation is finished | () => void | - |
-| banner | Whether to show as banner | boolean | false |
-| closable | Whether Alert can be closed | boolean | - |
-| closeText | Close text to show | string\|slot | - |
-| description | Additional content of Alert | string\|slot | - |
-| icon | Custom icon, effective when `showIcon` is `true` | vnode \| slot | - |
-| message | Content of Alert | string\|slot | - |
-| showIcon | Whether to show icon | boolean | false, in `banner` mode default is true |
-| type | Type of Alert styles, options: `success`, `info`, `warning`, `error` | string | `info`, in `banner` mode default is `warning` |
+| Property | Description | Type | Default | Version |
+| --- | --- | --- | --- | --- |
+| afterClose | Called when close animation is finished | () => void | - | - |
+| banner | Whether to show as banner | boolean | false | - |
+| closable | Whether Alert can be closed | boolean | - | - |
+| closeText | Close text to show | string\|slot | - | - |
+| description | Additional content of Alert | string\|slot | - | - |
+| icon | Custom icon, effective when `showIcon` is `true` | vnode \| slot | - | - |
+| message | Content of Alert | string\|slot | - | - |
+| showIcon | Whether to show icon | boolean | false, in `banner` mode default is true | - |
+| type | Type of Alert styles, options: `success`, `info`, `warning`, `error` | string | `info`, in `banner` mode default is `warning` | - |
### events
-| Events Name | Description | Arguments |
-| ----------- | ----------------------------- | ----------------------- |
-| close | Callback when Alert is closed | (e: MouseEvent) => void |
+| Events Name | Description | Arguments | Version |
+| ----------- | ----------------------------- | ----------------------- | ------- |
+| close | Callback when Alert is closed | (e: MouseEvent) => void | - |
diff --git a/components/alert/index.jsx b/components/alert/index.jsx
index c73640efe..f22bd54c7 100644
--- a/components/alert/index.jsx
+++ b/components/alert/index.jsx
@@ -7,6 +7,7 @@ import { getComponentFromProp, isValidElement } from '../_util/props-util';
import { cloneElement } from '../_util/vnode';
import { ConfigConsumerProps } from '../config-provider';
import Base from '../base';
+
function noop() {}
export const AlertProps = {
/**
@@ -42,7 +43,7 @@ const Alert = {
},
data() {
return {
- closing: true,
+ closing: false,
closed: false,
};
},
@@ -56,14 +57,14 @@ const Alert = {
dom.style.height = `${dom.offsetHeight}px`;
this.setState({
- closing: false,
+ closing: true,
});
this.$emit('close', e);
},
animationEnd() {
this.setState({
+ closing: false,
closed: true,
- closing: true,
});
this.afterClose();
},
@@ -84,8 +85,7 @@ const Alert = {
// banner模式默认为警告
type = banner && type === undefined ? 'warning' : type || 'info';
let iconTheme = 'filled';
- // should we give a warning?
- // warning(!iconType, `The property 'iconType' is deprecated. Use the property 'icon' instead.`);
+
if (!iconType) {
switch (type) {
case 'success':
@@ -117,7 +117,7 @@ const Alert = {
const alertCls = classNames(prefixCls, {
[`${prefixCls}-${type}`]: true,
- [`${prefixCls}-close`]: !closing,
+ [`${prefixCls}-closing`]: closing,
[`${prefixCls}-with-description`]: !!description,
[`${prefixCls}-no-icon`]: !showIcon,
[`${prefixCls}-banner`]: !!banner,
@@ -125,8 +125,12 @@ const Alert = {
});
const closeIcon = closable ? (
-
- {closeText || }
+
+ {closeText ? (
+ {closeText}
+ ) : (
+
+ )}
) : null;
@@ -145,7 +149,7 @@ const Alert = {
});
return closed ? null : (
-
+
{showIcon ? iconNode : null}
{message}
{description}
diff --git a/components/alert/index.zh-CN.md b/components/alert/index.zh-CN.md
index e849ba6b5..e4461ea1a 100644
--- a/components/alert/index.zh-CN.md
+++ b/components/alert/index.zh-CN.md
@@ -1,19 +1,19 @@
## API
-| 参数 | 说明 | 类型 | 默认值 |
-| --- | --- | --- | --- |
-| afterClose | 关闭动画结束后触发的回调函数 | () => void | - |
-| banner | 是否用作顶部公告 | boolean | false |
-| closable | 默认不显示关闭按钮 | boolean | 无 |
-| closeText | 自定义关闭按钮 | string\|slot | 无 |
-| description | 警告提示的辅助性文字介绍 | string\|slot | 无 |
-| icon | 自定义图标,`showIcon` 为 `true` 时有效 | vnode \| slot | - |
-| message | 警告提示内容 | string\|slot | 无 |
-| showIcon | 是否显示辅助图标 | boolean | false,`banner` 模式下默认值为 true |
-| type | 指定警告提示的样式,有四种选择 `success`、`info`、`warning`、`error` | string | `info`,`banner` 模式下默认值为 `warning` |
+| 参数 | 说明 | 类型 | 默认值 | 版本 |
+| --- | --- | --- | --- | --- |
+| afterClose | 关闭动画结束后触发的回调函数 | () => void | - | - |
+| banner | 是否用作顶部公告 | boolean | false | - |
+| closable | 默认不显示关闭按钮 | boolean | 无 | - |
+| closeText | 自定义关闭按钮 | string\|slot | 无 | - |
+| description | 警告提示的辅助性文字介绍 | string\|slot | 无 | - |
+| icon | 自定义图标,`showIcon` 为 `true` 时有效 | vnode \| slot | - | - |
+| message | 警告提示内容 | string\|slot | 无 | - |
+| showIcon | 是否显示辅助图标 | boolean | false,`banner` 模式下默认值为 true | - |
+| type | 指定警告提示的样式,有四种选择 `success`、`info`、`warning`、`error` | string | `info`,`banner` 模式下默认值为 `warning` | - |
### 事件
-| 事件名称 | 说明 | 回调参数 |
-| -------- | -------------------- | ----------------------- |
-| close | 关闭时触发的回调函数 | (e: MouseEvent) => void |
+| 事件名称 | 说明 | 回调参数 | 版本 |
+| -------- | -------------------- | ----------------------- | ---- |
+| close | 关闭时触发的回调函数 | (e: MouseEvent) => void | - |