Skip to content

Commit 4e3fbf0

Browse files
authored
chore(#9): update javascript behaviours (#146)
1 parent 37a1b3b commit 4e3fbf0

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/components/MenuItem.vue

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383

8484
<script>
8585
import ThemeMixin from "../mixins/theme"
86+
import CivicThemeCollapsible from '@civictheme/uikit/components/00-base/collapsible/collapsible'
87+
import CivicThemeFlyout from '@civictheme/uikit/components/00-base/flyout/flyout'
8688
8789
export default {
8890
mixins: [ThemeMixin],
@@ -114,39 +116,27 @@ export default {
114116
// Attach client side only javascript.
115117
if (!process.client) return
116118
if (this.isCollapsible) {
117-
delete require.cache[require.resolve('@civictheme/uikit/components/00-base/collapsible/collapsible')]
118-
require('@civictheme/uikit/components/00-base/collapsible/collapsible')
119+
new CivicThemeCollapsible(this.$el)
119120
}
120121
121122
if (this.isFlyout) {
122-
delete require.cache[require.resolve('@civictheme/uikit/components/00-base/flyout/flyout')]
123-
require('@civictheme/uikit/components/00-base/flyout/flyout')
123+
new CivicThemeFlyout(this.$el)
124124
}
125125
}
126126
catch(e) {
127127
// eslint-disable-next-line
128128
console.error(e)
129129
}
130130
},
131-
132-
detachJs() {
133-
if (this.isCollapsible) delete require.cache[require.resolve('@civictheme/uikit/components/00-base/collapsible/collapsible')]
134-
if (this.isFlyout) delete require.cache[require.resolve('@civictheme/uikit/components/00-base/flyout/flyout')]
135-
}
136131
},
137132
138-
created() {
133+
mounted() {
139134
this.attachJs()
140135
},
141136
142-
beforeDestroy() {
143-
this.detachJs()
144-
},
145-
146137
watch: {
147138
item(to) {
148139
if (to.children.length) {
149-
this.detachJs()
150140
this.attachJs()
151141
}
152142
}

0 commit comments

Comments
 (0)