Skip to content

Commit

Permalink
Import custom MutationObserver; remove mutation observer before compo…
Browse files Browse the repository at this point in the history
…nent get destroyed
  • Loading branch information
cheng-kang committed Oct 30, 2017
1 parent 7988575 commit 3be0aa1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/tabs/tabs.vue
Expand Up @@ -26,7 +26,7 @@
<script>
import Icon from '../icon/icon.vue';
import Render from '../base/render';
import { oneOf } from '../../utils/assist';
import { oneOf, MutationObserver } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
import elementResizeDetectorMaker from 'element-resize-detector';
Expand Down Expand Up @@ -342,18 +342,19 @@
const hiddenParentNode = this.isInsideHiddenElement();
if (hiddenParentNode) {
const mutationObserver = new MutationObserver(() => {
this.mutationObserver = new MutationObserver(() => {
if (hiddenParentNode.style.display !== 'none') {
this.updateBar();
mutationObserver.disconnect();
this.mutationObserver.disconnect();
}
});
mutationObserver.observe(hiddenParentNode, { attributes: true, childList: true, characterData: true, attributeFilter: ['style'] });
this.mutationObserver.observe(hiddenParentNode, { attributes: true, childList: true, characterData: true, attributeFilter: ['style'] });
}
},
beforeDestroy() {
this.observer.removeListener(this.$refs.navWrap, this.handleResize);
this.mutationObserver.disconnect();
}
};
</script>

0 comments on commit 3be0aa1

Please sign in to comment.