blob: 34a1d1facda34e80159f76b149dd3e398798498f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<script>
export default {
data() {
return {
hasChildren: false,
};
},
mounted() {
const setHasChildren = () => {
this.hasChildren = Boolean(this.$el.innerText.trim());
};
// Set initial.
setHasChildren();
if (!this.hasChildren) {
// Observe children changed.
this.observer = new MutationObserver(() => {
setHasChildren();
if (this.hasChildren) {
this.observer.disconnect();
this.observer = undefined;
}
});
this.observer.observe(this.$el, { childList: true, subtree: true });
}
},
beforeUnmount() {
if (this.observer) {
this.observer.disconnect();
}
},
};
</script>
<template>
<div v-show="hasChildren" class="mr-section-container mr-widget-workflow">
<slot></slot>
</div>
</template>
|