breaking change: rename get-container to teleport

This commit is contained in:
chenjiahan
2020-08-21 10:58:02 +08:00
parent 07d1a2590f
commit 52b187692b
39 changed files with 154 additions and 127 deletions

View File

@@ -130,7 +130,7 @@ export default {
| closeable `v2.5.0` | Whether to show close icon | _boolean_ | `false` |
| closeIcon `v2.5.0` | Close icon name | _string_ | `clear` |
| closeIconPosition `v2.5.0` | Close icon positioncan be set to `top-left` `bottom-left` `bottom-right` | _string_ | `top-right` |
| getContainer | Return the mount node for ImagePreview | _string \| () => Element_ | - |
| teleport | Return the mount node for ImagePreview | _string \| Element_ | - |
### Props
@@ -150,7 +150,7 @@ export default {
| closeable `v2.5.0` | Whether to show close icon | _boolean_ | `false` |
| close-icon `v2.5.0` | Close icon name | _string_ | `clear` |
| close-icon-position `v2.5.0` | Close icon positioncan be set to `top-left` `bottom-left` `bottom-right` | _string_ | `top-right` |
| get-container | Return the mount node for ImagePreview | _string \| () => Element_ | - |
| teleport | Return the mount node for ImagePreview | _string \| Element_ | - |
### Events

View File

@@ -166,7 +166,7 @@ export default {
| closeable `v2.5.0` | 是否显示关闭图标 | _boolean_ | `false` |
| closeIcon `v2.5.0` | 关闭图标名称或图片链接 | _string_ | `clear` |
| closeIconPosition `v2.5.0` | 关闭图标位置,可选值为`top-left`<br>`bottom-left` `bottom-right` | _string_ | `top-right` |
| getContainer | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - |
| teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | - |
### Props
@@ -188,7 +188,7 @@ export default {
| closeable `v2.5.0` | 是否显示关闭图标 | _boolean_ | `false` |
| close-icon `v2.5.0` | 关闭图标名称或图片链接 | _string_ | `clear` |
| close-icon-position `v2.5.0` | 关闭图标位置,可选值为`top-left`<br>`bottom-left` `bottom-right` | _string_ | `top-right` |
| get-container | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - |
| teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | - |
### Events

View File

@@ -12,12 +12,12 @@ const defaultConfig = {
onScale: null,
onClose: null,
onChange: null,
teleport: 'body',
className: '',
showIndex: true,
closeable: false,
closeIcon: 'clear',
asyncClose: false,
getContainer: 'body',
startPosition: 0,
swipeDuration: 500,
showIndicators: false,

View File

@@ -336,7 +336,7 @@ test('ImagePreview.Component', () => {
test('get container with function call ', async (done) => {
const element = document.createElement('div');
document.body.appendChild(element);
ImagePreview({ images, getContainer: () => element });
ImagePreview({ images, teleport: element });
await Vue.nextTick();
const wrapperDiv = document.querySelector('.van-image-preview');
@@ -358,22 +358,22 @@ test('get container with component call', () => {
const wrapper = mount({
template: `
<div>
<van-image-preview :value="true" :get-container="getContainer">
<van-image-preview :value="true" :teleport="teleport">
</van-image-preview>
</div>
`,
data() {
return {
getContainer: () => div1,
teleport: () => div1,
};
},
});
const imageView = wrapper.find('.van-image-preview').element;
expect(imageView.parentNode).toEqual(div1);
wrapper.vm.getContainer = () => div2;
wrapper.vm.teleport = () => div2;
expect(imageView.parentNode).toEqual(div2);
wrapper.vm.getContainer = null;
wrapper.vm.teleport = null;
expect(wrapper.element).toEqual(wrapper.element);
});