Merge remote-tracking branch 'origin/master' into antd-3.0

This commit is contained in:
ddcat1115 2017-08-24 10:45:02 +08:00
commit aa9f97dfda
4 changed files with 14 additions and 33 deletions

View File

@ -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(<Card title="xxx">xxx</Card>);
fakeResizeWindowTo(wrapper, 1000);
await delay(0);

View File

@ -39,17 +39,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
> <Modal key={this.state.newKey} visible={this.state.visible} />
> ```
> Another way is to conditionally mount modal.
> ```jsx
> {this.state.visible && <Modal visible={true} />}
> ```
> If you wish to open it with brand new state everytime, you need to reset state manually.
### Modal.method()

View File

@ -38,17 +38,7 @@ title: Modal
#### 清空旧数据
> `<Modal />` 组件有标准的 React 生命周期,关闭后状态不会自动清空。
> 如果希望每次打开都是新内容,需要自行手动清空旧的状态。或者打开时给 Modal 设置一个[全新的 key](https://github.com/ant-design/ant-design/issues/4165) React 会渲染出一个全新的对话框。
> ```jsx
> <Modal key={this.state.newKey} visible={this.state.visible} />
> ```
> 另一种方式是根据条件加载 Modal。
> ```jsx
> {this.state.visible && <Modal visible={true} />}
> ```
> 如果希望每次打开都是新内容,需要自行手动清空旧的状态。
### Modal.method()

View File

@ -12,18 +12,18 @@ if (typeof window !== 'undefined') {
};
};
window.matchMedia = window.matchMedia || matchMediaPolyfill;
const documentHTML = '<!doctype html><html><body><div id="root"></div></body></html>';
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 = '<!doctype html><html><body><div id="root"></div></body></html>';
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'));
};