From 61aac68028050fdb29ed08418af908b603d78736 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 24 Aug 2017 09:44:17 +0800 Subject: [PATCH 1/3] doc: remove new key way --- components/modal/index.en-US.md | 12 +----------- components/modal/index.zh-CN.md | 12 +----------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/components/modal/index.en-US.md b/components/modal/index.en-US.md index 99c144859f..005922e014 100644 --- a/components/modal/index.en-US.md +++ b/components/modal/index.en-US.md @@ -37,17 +37,7 @@ and so on. #### Destroy on close > The state of Modal will be preserved at it's component lifecircle. -> If you wish to open it with brand new state everytime, you need to reset state manually. Or simply [give a new key](https://github.com/ant-design/ant-design/issues/4165) to Modal when visible is changed to `true`, React will treat it as a new component. - -> ```jsx -> -> ``` - -> Another way is to conditionally mount modal. - -> ```jsx -> {this.state.visible && } -> ``` +> If you wish to open it with brand new state everytime, you need to reset state manually. ### Modal.method() diff --git a/components/modal/index.zh-CN.md b/components/modal/index.zh-CN.md index 637fe7b281..539ce875c1 100644 --- a/components/modal/index.zh-CN.md +++ b/components/modal/index.zh-CN.md @@ -36,17 +36,7 @@ title: Modal #### 清空旧数据 > `` 组件有标准的 React 生命周期,关闭后状态不会自动清空。 -> 如果希望每次打开都是新内容,需要自行手动清空旧的状态。或者打开时给 Modal 设置一个[全新的 key](https://github.com/ant-design/ant-design/issues/4165), React 会渲染出一个全新的对话框。 - -> ```jsx -> -> ``` - -> 另一种方式是根据条件加载 Modal。 - -> ```jsx -> {this.state.visible && } -> ``` +> 如果希望每次打开都是新内容,需要自行手动清空旧的状态。 ### Modal.method() From c355eae6d1840194dc472fd340e39b33a3a0a3a5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 24 Aug 2017 10:05:55 +0800 Subject: [PATCH 2/3] Fix node test --- components/card/__tests__/index.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/card/__tests__/index.test.js b/components/card/__tests__/index.test.js index 1c7155cd85..a4e72031f3 100644 --- a/components/card/__tests__/index.test.js +++ b/components/card/__tests__/index.test.js @@ -3,6 +3,7 @@ import { mount } from 'enzyme'; import Card from '../index'; const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout)); +const testMethod = typeof window !== 'undefined' ? it : xit; describe('Card', () => { function fakeResizeWindowTo(wrapper, width) { @@ -15,7 +16,7 @@ describe('Card', () => { window.resizeTo(width); } - it('resize card will trigger different padding', async () => { + testMethod('resize card will trigger different padding', async () => { const wrapper = mount(xxx); fakeResizeWindowTo(wrapper, 1000); await delay(0); From d0d6e108942b6d60fe65f210c25dd2ec53aff2a2 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 24 Aug 2017 10:19:13 +0800 Subject: [PATCH 3/3] Fix node test again --- tests/setup.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/setup.js b/tests/setup.js index 5a895ae2d2..2dfefb0cd4 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -12,18 +12,18 @@ if (typeof window !== 'undefined') { }; }; window.matchMedia = window.matchMedia || matchMediaPolyfill; + + const documentHTML = '
'; + global.document = jsdom(documentHTML); + global.window = document.parentWindow; + + global.window.resizeTo = (width, height) => { + global.window.innerWidth = width || global.window.innerWidth; + global.window.innerHeight = height || global.window.innerHeight; + global.window.dispatchEvent(new Event('resize')); + }; } global.requestAnimationFrame = global.requestAnimationFrame || function (cb) { return setTimeout(cb, 0); }; - -const documentHTML = '
'; -global.document = jsdom(documentHTML); -global.window = document.parentWindow; - -global.window.resizeTo = (width, height) => { - global.window.innerWidth = width || global.window.innerWidth; - global.window.innerHeight = height || global.window.innerHeight; - global.window.dispatchEvent(new Event('resize')); -};