chore: update destory to unmount

pull/2377/head^2
tanjinzhou 2020-06-11 16:13:09 +08:00
parent 7555f2c65b
commit 585bb7495b
61 changed files with 79 additions and 64 deletions

View File

@ -24,7 +24,7 @@ export default {
} }
}, },
beforeDestroy() { beforeUnmount() {
if (this.autoDestroy) { if (this.autoDestroy) {
this.removeContainer(); this.removeContainer();
} }

View File

@ -24,7 +24,7 @@ export default {
} }
}, },
beforeDestroy() { beforeUnmount() {
this.removeContainer(); this.removeContainer();
}, },
methods: { methods: {

View File

@ -46,7 +46,7 @@ export default {
} }
}, },
}, },
beforeDestroy() { beforeUnmount() {
const { visible } = this.$props; const { visible } = this.$props;
// 离开时不会 render 导到离开时数值不变,改用 func 。。 // 离开时不会 render 导到离开时数值不变,改用 func 。。
openCount = visible && openCount ? openCount - 1 : openCount; openCount = visible && openCount ? openCount - 1 : openCount;

View File

@ -1,13 +1,13 @@
const createRef = fn => { const createRef = fn => {
return { return {
onVnodeBeforeMounted: vnode => { onVnodeBeforeMount: vnode => {
fn(vnode.component || vnode.el, vnode.key); fn(vnode.component || vnode.el, vnode.key);
}, },
onVnodeUpdated: vnode => { onVnodeUpdated: vnode => {
fn(vnode.component || vnode.el, vnode.key); fn(vnode.component || vnode.el, vnode.key);
}, },
onVnodeDestroyed: vnode => { onVnodeUnmounted: vnode => {
fn(vnode.component || vnode.el, vnode.key); fn(null, vnode.key);
}, },
}; };
}; };

View File

@ -44,7 +44,7 @@ export default function connect(mapStateToProps) {
this.trySubscribe(); this.trySubscribe();
}, },
beforeDestroy() { beforeUnmount() {
this.tryUnsubscribe(); this.tryUnsubscribe();
}, },
methods: { methods: {

View File

@ -37,7 +37,7 @@ export default {
configProvider, configProvider,
}; };
}, },
beforeDestroy() { beforeUnmount() {
if (this.instance) { if (this.instance) {
this.instance.cancel(); this.instance.cancel();
} }

View File

@ -98,7 +98,7 @@ const Affix = {
this.updatePosition(); this.updatePosition();
}, },
}, },
beforeDestroy() { beforeUnmount() {
clearTimeout(this.timeout); clearTimeout(this.timeout);
removeObserveTarget(this); removeObserveTarget(this);
this.updatePosition.cancel(); this.updatePosition.cancel();

View File

@ -152,7 +152,7 @@ export default {
this.updateInk(); this.updateInk();
}); });
}, },
beforeDestroy() { beforeUnmount() {
if (this.scrollEvent) { if (this.scrollEvent) {
this.scrollEvent.remove(); this.scrollEvent.remove();
} }

View File

@ -36,7 +36,7 @@ export default {
this.antAnchor.registerLink(this.href); this.antAnchor.registerLink(this.href);
}, },
beforeDestroy() { beforeUnmount() {
this.antAnchor.unregisterLink(this.href); this.antAnchor.unregisterLink(this.href);
}, },
methods: { methods: {

View File

@ -44,7 +44,7 @@ const BackTop = {
}); });
}, },
beforeDestroy() { beforeUnmount() {
if (this.scrollEvent) { if (this.scrollEvent) {
this.scrollEvent.remove(); this.scrollEvent.remove();
} }

View File

@ -65,7 +65,7 @@ export default {
}); });
} }
}, },
beforeDestroy() { beforeUnmount() {
this.clearTimeout(); this.clearTimeout();
}, },
methods: { methods: {

View File

@ -50,7 +50,7 @@ export default {
updated() { updated() {
this.fixTwoCNChar(); this.fixTwoCNChar();
}, },
beforeDestroy() { beforeUnmount() {
if (this.delayTimeout) { if (this.delayTimeout) {
clearTimeout(this.delayTimeout); clearTimeout(this.delayTimeout);
} }

View File

@ -108,7 +108,7 @@ const Carousel = {
// https://github.com/ant-design/ant-design/issues/7191 // https://github.com/ant-design/ant-design/issues/7191
this.innerSlider = this.$refs.slick && this.$refs.slick.innerSlider; this.innerSlider = this.$refs.slick && this.$refs.slick.innerSlider;
}, },
beforeDestroy() { beforeUnmount() {
const { autoplay } = this; const { autoplay } = this;
if (autoplay) { if (autoplay) {
window.removeEventListener('resize', this.onWindowResized); window.removeEventListener('resize', this.onWindowResized);

View File

@ -53,7 +53,7 @@ export default {
'`value` is not validate prop, do you mean `checked`?', '`value` is not validate prop, do you mean `checked`?',
); );
}, },
beforeDestroy() { beforeUnmount() {
const { value, checkboxGroupContext: checkboxGroup = {} } = this; const { value, checkboxGroupContext: checkboxGroup = {} } = this;
if (checkboxGroup.cancelValue) { if (checkboxGroup.cancelValue) {
checkboxGroup.cancelValue(value); checkboxGroup.cancelValue(value);

View File

@ -194,7 +194,7 @@ const Descriptions = {
}); });
}); });
}, },
beforeDestroy() { beforeUnmount() {
ResponsiveObserve.unsubscribe(this.token); ResponsiveObserve.unsubscribe(this.token);
}, },
render() { render() {

View File

@ -85,7 +85,7 @@ const Drawer = {
this.preVisible = this.visible; this.preVisible = this.visible;
}); });
}, },
beforeDestroy() { beforeUnmount() {
// unmount drawer in child, clear push. // unmount drawer in child, clear push.
if (this.parentDrawer) { if (this.parentDrawer) {
this.parentDrawer.pull(); this.parentDrawer.pull();

View File

@ -121,7 +121,7 @@ export default {
this.initialValue = cloneDeep(this.fieldValue); this.initialValue = cloneDeep(this.fieldValue);
} }
}, },
beforeDestroy() { beforeUnmount() {
const { removeField } = this.FormContext; const { removeField } = this.FormContext;
removeField && removeField(this); removeField && removeField(this);
}, },

View File

@ -106,7 +106,7 @@ export default {
this.collectContext(); this.collectContext();
} }
}, },
beforeDestroy() { beforeUnmount() {
this.collectFormItemContext(this.$vnode && this.$vnode.context, 'delete'); this.collectFormItemContext(this.$vnode && this.$vnode.context, 'delete');
}, },
mounted() { mounted() {

View File

@ -48,7 +48,7 @@ export default {
}); });
}); });
}, },
beforeDestroy() { beforeUnmount() {
ResponsiveObserve.unsubscribe(this.token); ResponsiveObserve.unsubscribe(this.token);
}, },
methods: { methods: {

View File

@ -82,7 +82,7 @@ export default {
this.clearPasswordValueAttribute(); this.clearPasswordValueAttribute();
}); });
}, },
beforeDestroy() { beforeUnmount() {
if (this.removePasswordTimeout) { if (this.removePasswordTimeout) {
clearTimeout(this.removePasswordTimeout); clearTimeout(this.removePasswordTimeout);
} }

View File

@ -31,7 +31,7 @@ const ResizableTextArea = {
mounted() { mounted() {
this.resizeTextarea(); this.resizeTextarea();
}, },
beforeDestroy() { beforeUnmount() {
raf.cancel(this.nextFrameActionId); raf.cancel(this.nextFrameActionId);
raf.cancel(this.resizeFrameId); raf.cancel(this.resizeFrameId);
}, },

View File

@ -145,7 +145,7 @@ export default {
}); });
}, },
beforeDestroy() { beforeUnmount() {
if (this.mql) { if (this.mql) {
this.mql.removeListener(this.responsiveHandler); this.mql.removeListener(this.responsiveHandler);
} }

View File

@ -65,7 +65,7 @@ const LocaleProvider = {
setMomentLocale(locale); setMomentLocale(locale);
changeConfirmLocale(locale && locale.Modal); changeConfirmLocale(locale && locale.Modal);
}, },
beforeDestroy() { beforeUnmount() {
changeConfirmLocale(); changeConfirmLocale();
}, },
render() { render() {

View File

@ -64,7 +64,7 @@ const Menu = {
updated() { updated() {
this.propsUpdating = false; this.propsUpdating = false;
}, },
// beforeDestroy() { // beforeUnmount() {
// raf.cancel(this.mountRafId); // raf.cancel(this.mountRafId);
// }, // },
watch: { watch: {

View File

@ -24,7 +24,7 @@ export default {
this.timeoutId = setTimeout(() => this.$el.focus()); this.timeoutId = setTimeout(() => this.$el.focus());
} }
}, },
beforeDestroy() { beforeUnmount() {
clearTimeout(this.timeoutId); clearTimeout(this.timeoutId);
}, },
methods: { methods: {

View File

@ -66,7 +66,7 @@ export default {
this.updateSpinning(); this.updateSpinning();
}); });
}, },
beforeDestroy() { beforeUnmount() {
this.cancelExistingSpin(); this.cancelExistingSpin();
}, },
methods: { methods: {

View File

@ -28,7 +28,7 @@ export default {
this.syncTimer(); this.syncTimer();
}, },
beforeDestroy() { beforeUnmount() {
this.stopTimer(); this.stopTimer();
}, },

View File

@ -18,7 +18,7 @@ export default {
this.subscribe(); this.subscribe();
}, },
beforeDestroy() { beforeUnmount() {
if (this.unsubscribe) { if (this.unsubscribe) {
this.unsubscribe(); this.unsubscribe();
} }

View File

@ -125,7 +125,7 @@ export default {
this.subscribe(); this.subscribe();
}, },
beforeDestroy() { beforeUnmount() {
if (this.unsubscribe) { if (this.unsubscribe) {
this.unsubscribe(); this.unsubscribe();
} }

View File

@ -25,7 +25,7 @@ export default function createBodyRow(Component = 'tr') {
this.subscribe(); this.subscribe();
}, },
beforeDestroy() { beforeUnmount() {
if (this.unsubscribe) { if (this.unsubscribe) {
this.unsubscribe(); this.unsubscribe();
} }

View File

@ -92,7 +92,7 @@ export default {
// } // }
// }); // });
// }, // },
beforeDestroy() { beforeUnmount() {
clearTimeout(this.triggerScrollTimer); clearTimeout(this.triggerScrollTimer);
// if (this.scrollEvent) { // if (this.scrollEvent) {
// this.scrollEvent.remove(); // this.scrollEvent.remove();

View File

@ -46,7 +46,7 @@ const ListBody = {
}); });
}, },
beforeDestroy() { beforeUnmount() {
raf.cancel(this.mountId); raf.cancel(this.mountId);
raf.cancel(this.lazyId); raf.cancel(this.lazyId);
}, },

View File

@ -48,7 +48,7 @@ export default {
this.sFileList = val || []; this.sFileList = val || [];
}, },
}, },
beforeDestroy() { beforeUnmount() {
this.clearProgressTimer(); this.clearProgressTimer();
}, },
methods: { methods: {

View File

@ -94,7 +94,7 @@ export default {
this.prevProps = { ...this.$props, align: clonedeep(this.$props.align) }; this.prevProps = { ...this.$props, align: clonedeep(this.$props.align) };
}); });
}, },
beforeDestroy() { beforeUnmount() {
this.stopMonitorWindowResize(); this.stopMonitorWindowResize();
}, },
methods: { methods: {

View File

@ -80,7 +80,7 @@ const Picker = {
this.preSOpen = this.sOpen; this.preSOpen = this.sOpen;
}, },
beforeDestroy() { beforeUnmount() {
clearTimeout(this.focusTimeout); clearTimeout(this.focusTimeout);
}, },
methods: { methods: {

View File

@ -96,7 +96,7 @@ export default {
} }
}); });
}, },
beforeDestroy() { beforeUnmount() {
const { visible, getOpenCount } = this; const { visible, getOpenCount } = this;
if ((visible || this.inTransition) && !getOpenCount()) { if ((visible || this.inTransition) && !getOpenCount()) {
this.switchScrollingEffect(); this.switchScrollingEffect();

View File

@ -130,7 +130,7 @@ const Drawer = {
} }
}); });
}, },
beforeDestroy() { beforeUnmount() {
delete currentDrawer[this.drawerId]; delete currentDrawer[this.drawerId];
delete this.isOpenChange; delete this.isOpenChange;
if (this.container) { if (this.container) {

View File

@ -174,7 +174,7 @@ export default {
this.updatedFunc(); this.updatedFunc();
}); });
}, },
beforeDestroy() { beforeUnmount() {
this.stop(); this.stop();
}, },
methods: { methods: {

View File

@ -73,7 +73,7 @@ export default {
this.scrollHander = addEventListener(eventNode, 'scroll', this.lazyLoadHandler); this.scrollHander = addEventListener(eventNode, 'scroll', this.lazyLoadHandler);
}); });
}, },
beforeDestroy() { beforeUnmount() {
this._mounted = false; this._mounted = false;
if (this.lazyLoadHandler.cancel) { if (this.lazyLoadHandler.cancel) {
this.lazyLoadHandler.cancel(); this.lazyLoadHandler.cancel();

View File

@ -80,7 +80,7 @@ const DOMWrap = {
}); });
}, },
beforeDestroy() { beforeUnmount() {
if (this.resizeObserver) { if (this.resizeObserver) {
this.resizeObserver.disconnect(); this.resizeObserver.disconnect();
} }

View File

@ -59,7 +59,7 @@ const MenuItem = {
}); });
this.callRef(); this.callRef();
}, },
beforeDestroy() { beforeUnmount() {
const props = this.$props; const props = this.$props;
this.__emit('destroy', props.eventKey); this.__emit('destroy', props.eventKey);
}, },

View File

@ -102,7 +102,7 @@ const SubMenu = {
}); });
}, },
beforeDestroy() { beforeUnmount() {
const { eventKey } = this; const { eventKey } = this;
this.__emit('destroy', eventKey); this.__emit('destroy', eventKey);

View File

@ -28,9 +28,9 @@ export default {
} }
}, },
beforeDestroy() { beforeUnmount() {
this.clearCloseTimer(); this.clearCloseTimer();
this.willDestroy = true; // beforeDestroyonMouseleave this.willDestroy = true; // beforeUnmountonMouseleave
}, },
methods: { methods: {
close(e) { close(e) {

View File

@ -23,7 +23,7 @@ const VueResizeObserver = {
updated() { updated() {
this.onComponentUpdated(); this.onComponentUpdated();
}, },
beforeDestroy() { beforeUnmount() {
this.destroyObserver(); this.destroyObserver();
}, },
methods: { methods: {

View File

@ -63,7 +63,7 @@ export default {
this.lastInputValue = props.inputValue; this.lastInputValue = props.inputValue;
this.prevVisible = this.visible; this.prevVisible = this.visible;
}, },
beforeDestroy() { beforeUnmount() {
if (this.rafInstance) { if (this.rafInstance) {
raf.cancel(this.rafInstance); raf.cancel(this.rafInstance);
} }

View File

@ -200,7 +200,7 @@ const Select = {
this.forcePopupAlign(); this.forcePopupAlign();
}); });
}, },
beforeDestroy() { beforeUnmount() {
this.clearFocusTime(); this.clearFocusTime();
this.clearBlurTime(); this.clearBlurTime();
this.clearComboboxTime(); this.clearComboboxTime();

View File

@ -82,7 +82,7 @@ export default {
this.setDropdownWidth(); this.setDropdownWidth();
}); });
}, },
beforeDestroy() { beforeUnmount() {
this.cancelRafInstance(); this.cancelRafInstance();
}, },
methods: { methods: {

View File

@ -489,7 +489,7 @@ export default {
} }
}); });
}, },
beforeDestroy() { beforeUnmount() {
if (this.animationEndCallback) { if (this.animationEndCallback) {
clearTimeout(this.animationEndCallback); clearTimeout(this.animationEndCallback);
} }

View File

@ -87,7 +87,7 @@ export default {
}); });
} }
}, },
beforeDestroy() { beforeUnmount() {
this._responsiveMediaHandlers.forEach(function(obj) { this._responsiveMediaHandlers.forEach(function(obj) {
enquire.unregister(obj.query, obj.handler); enquire.unregister(obj.query, obj.handler);
}); });

View File

@ -31,7 +31,7 @@ export default {
// so we listen on document here. // so we listen on document here.
this.onMouseUpListener = addEventListener(document, 'mouseup', this.handleMouseUp); this.onMouseUpListener = addEventListener(document, 'mouseup', this.handleMouseUp);
}, },
beforeDestroy() { beforeUnmount() {
if (this.onMouseUpListener) { if (this.onMouseUpListener) {
this.onMouseUpListener.remove(); this.onMouseUpListener.remove();
} }

View File

@ -81,7 +81,7 @@ export default function createSlider(Component) {
} }
}); });
}, },
beforeDestroy() { beforeUnmount() {
this.$nextTick(() => { this.$nextTick(() => {
// if (super.componentWillUnmount) super.componentWillUnmount() // if (super.componentWillUnmount) super.componentWillUnmount()
this.removeDocumentEvents(); this.removeDocumentEvents();

View File

@ -46,7 +46,7 @@ export default {
this.calcStepOffsetWidth(); this.calcStepOffsetWidth();
}); });
}, },
beforeDestroy() { beforeUnmount() {
if (this.calcTimeout) { if (this.calcTimeout) {
clearTimeout(this.calcTimeout); clearTimeout(this.calcTimeout);
} }

View File

@ -25,7 +25,7 @@ const ExpandableRow = {
// children: PropTypes.func.isRequired, // children: PropTypes.func.isRequired,
}, },
beforeDestroy() { beforeUnmount() {
this.handleDestroy(); this.handleDestroy();
}, },
methods: { methods: {

View File

@ -203,7 +203,7 @@ export default {
}); });
}, },
beforeDestroy() { beforeUnmount() {
if (this.resizeEvent) { if (this.resizeEvent) {
this.resizeEvent.remove(); this.resizeEvent.remove();
} }

View File

@ -58,7 +58,7 @@ export default {
}); });
}, },
beforeDestroy() { beforeUnmount() {
if (this.resizeObserver) { if (this.resizeObserver) {
this.resizeObserver.disconnect(); this.resizeObserver.disconnect();
} }

View File

@ -80,7 +80,7 @@ export default {
} }
}, },
}, },
beforeDestroy() { beforeUnmount() {
this.destroy = true; this.destroy = true;
raf.cancel(this.sentinelId); raf.cancel(this.sentinelId);
}, },

View File

@ -78,7 +78,7 @@ const TreeNode = {
updated() { updated() {
this.syncLoadData(this.$props); this.syncLoadData(this.$props);
}, },
beforeDestroy() { beforeUnmount() {
const { const {
eventKey, eventKey,
vcTree: { registerTreeNode }, vcTree: { registerTreeNode },

View File

@ -62,7 +62,7 @@ export default {
this.setStretchSize(); this.setStretchSize();
}); });
}, },
beforeDestroy() { beforeUnmount() {
if (this.$el.parentNode) { if (this.$el.parentNode) {
this.$el.parentNode.removeChild(this.$el); this.$el.parentNode.removeChild(this.$el);
} else if (this.$el.remove) { } else if (this.$el.remove) {

View File

@ -125,7 +125,7 @@ export default {
}); });
}, },
beforeDestroy() { beforeUnmount() {
this.clearDelayTimer(); this.clearDelayTimer();
this.clearOutsideHandler(); this.clearOutsideHandler();
clearTimeout(this.mouseDownTimeout); clearTimeout(this.mouseDownTimeout);

View File

@ -45,7 +45,7 @@ const AjaxUploader = {
mounted() { mounted() {
this._isMounted = true; this._isMounted = true;
}, },
beforeDestroy() { beforeUnmount() {
this._isMounted = false; this._isMounted = false;
this.abort(); this.abort();
}, },

View File

@ -1,3 +1,18 @@
<template> <template>
<a-empty /> <div>
<a-button @click="show = !show">按钮</a-button>
<a-tooltip class="ddddd" style="color: blue" v-if="show">
<template v-slot:title>prompt text</template>
<a-button class="test" style="color: red">Tooltip will show when mouse enter.</a-button>
</a-tooltip>
</div>
</template> </template>
<script>
export default {
data() {
return {
show: true,
};
},
};
</script>