[bugfix] Toast: should not render overlay when cleared (#3025)

This commit is contained in:
neverland 2019-03-21 14:18:50 +08:00 committed by GitHub
parent 5c0ae2dc06
commit 055387108f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -186,6 +186,10 @@ export const PopupMixin = {
}, },
renderOverlay() { renderOverlay() {
if (this.$isServer || !this.value) {
return;
}
if (this.overlay) { if (this.overlay) {
openOverlay(this, { openOverlay(this, {
zIndex: context.zIndex++, zIndex: context.zIndex++,

View File

@ -117,6 +117,35 @@ test('render overlay', () => {
expect(div.querySelector('.van-overlay')).toBeTruthy(); expect(div.querySelector('.van-overlay')).toBeTruthy();
}); });
test('watch overlay prop', () => {
const div = document.createElement('div');
wrapper = mount({
template: `
<div>
<popup :value="show" :overlay="overlay" :get-container="getContainer" />
</div>
`,
components: {
Popup
},
data() {
return {
show: false,
overlay: false,
getContainer: () => div
};
}
});
expect(div.querySelector('.van-overlay')).toBeFalsy();
wrapper.setData({ overlay: true });
expect(div.querySelector('.van-overlay')).toBeFalsy();
wrapper.setData({ show: true });
expect(div.querySelector('.van-overlay')).toBeTruthy();
});
test('close on click modal', () => { test('close on click modal', () => {
const div = document.createElement('div'); const div = document.createElement('div');
wrapper = mount({ wrapper = mount({