fix: portal error, close #6880 #6837 #6807

pull/6917/head
tangjinzhou 1 year ago
parent 6c13c964c5
commit 72e148cae8

@ -1,13 +1,5 @@
import PropTypes from './vue-types';
import {
defineComponent,
nextTick,
onBeforeMount,
onBeforeUnmount,
onUpdated,
Teleport,
watch,
} from 'vue';
import { defineComponent, nextTick, onBeforeMount, onUpdated, Teleport, watch } from 'vue';
import { useInjectPortal } from '../vc-trigger/context';
export default defineComponent({
@ -44,11 +36,11 @@ export default defineComponent({
}
});
});
onBeforeUnmount(() => {
if (container && container.parentNode) {
container.parentNode.removeChild(container);
}
});
// onBeforeUnmount(() => {
// if (container && container.parentNode) {
// container.parentNode.removeChild(container);
// }
// });
return () => {
if (!shouldRender.value) return null;
if (isSSR) {

@ -61,11 +61,13 @@ export default defineComponent({
const container = shallowRef<HTMLElement>();
const componentRef = shallowRef();
const rafId = shallowRef<number>();
const defaultContainer = canUseDom() && document.createElement('div');
const removeCurrentContainer = () => {
// Portal will remove from `parentNode`.
// Let's handle this again to avoid refactor issue.
container.value?.parentNode?.removeChild(container.value);
if (container.value === defaultContainer) {
container.value?.parentNode?.removeChild(container.value);
}
container.value = null;
};
let parent: HTMLElement = null;
@ -82,8 +84,6 @@ export default defineComponent({
return true;
};
// attachToParent();
const defaultContainer = canUseDom() && document.createElement('div');
const getContainer = () => {
if (!supportDom) {
return null;

Loading…
Cancel
Save