mirror of
https://github.com/youzan/vant.git
synced 2026-04-26 01:01:51 +08:00
[Improvement] Popup: get-container support selector (#1699)
This commit is contained in:
@@ -48,7 +48,7 @@ Use `position` prop to set popup display position
|
||||
| transition | Transition | `String` | `popup-slide` |
|
||||
| lock-scroll | Whether to lock background scroll | `Boolean` | `true` |
|
||||
| lazy-render | Whether to lazy render util appeared | `Boolean` | `true` |
|
||||
| get-container | Return the mount node for Popup | `() => HTMLElement` | - |
|
||||
| get-container | Return the mount node for Popup | `String | () => HTMLElement` | - |
|
||||
|
||||
### Event
|
||||
|
||||
|
||||
@@ -76,6 +76,26 @@ test('get container with parent', () => {
|
||||
expect(popup.parentNode).toEqual(wrapper.element);
|
||||
});
|
||||
|
||||
test('get container with selector', () => {
|
||||
wrapper = mount({
|
||||
template: `
|
||||
<div>
|
||||
<popup class="get-container-selector-1" :value="true" get-container="body"></popup>
|
||||
<popup class="get-container-selector-2" :value="true" get-container="unknown"></popup>
|
||||
</div>
|
||||
`,
|
||||
components: {
|
||||
Popup
|
||||
}
|
||||
});
|
||||
|
||||
const dom1 = document.querySelector('.get-container-selector-1');
|
||||
const dom2 = wrapper.vm.$el.querySelector('.get-container-selector-2');
|
||||
|
||||
expect(dom1.parentNode).toEqual(document.body);
|
||||
expect(dom2.parentNode).toEqual(wrapper.vm.$el);
|
||||
});
|
||||
|
||||
test('render overlay', () => {
|
||||
const div = document.createElement('div');
|
||||
wrapper = mount({
|
||||
|
||||
@@ -48,7 +48,7 @@ export default {
|
||||
| close-on-click-overlay | 点击蒙层是否关闭 Popup | `Boolean` | `true` |
|
||||
| transition | transition 名称 | `String` | `popup-slide` |
|
||||
| lazy-render | 是否在首次显示弹层时才渲染 DOM 节点 | `Boolean` | `true` |
|
||||
| get-container | 指定弹出层挂载的 HTML 节点 | `() => HTMLElement` | - |
|
||||
| get-container | 指定挂载的节点,可以传入 CSS 选择器,<br>或一个返回 DOM 节点的函数 | `String | () => HTMLElement` | - |
|
||||
|
||||
### Event
|
||||
|
||||
|
||||
Reference in New Issue
Block a user