Skip to content

Commit

Permalink
chore(#9): update javascript behaviours (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher authored Mar 26, 2024
1 parent 37a1b3b commit 4e3fbf0
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/components/MenuItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@

<script>
import ThemeMixin from "../mixins/theme"
import CivicThemeCollapsible from '@civictheme/uikit/components/00-base/collapsible/collapsible'
import CivicThemeFlyout from '@civictheme/uikit/components/00-base/flyout/flyout'
export default {
mixins: [ThemeMixin],
Expand Down Expand Up @@ -114,39 +116,27 @@ export default {
// Attach client side only javascript.
if (!process.client) return
if (this.isCollapsible) {
delete require.cache[require.resolve('@civictheme/uikit/components/00-base/collapsible/collapsible')]
require('@civictheme/uikit/components/00-base/collapsible/collapsible')
new CivicThemeCollapsible(this.$el)
}
if (this.isFlyout) {
delete require.cache[require.resolve('@civictheme/uikit/components/00-base/flyout/flyout')]
require('@civictheme/uikit/components/00-base/flyout/flyout')
new CivicThemeFlyout(this.$el)
}
}
catch(e) {
// eslint-disable-next-line
console.error(e)
}
},
detachJs() {
if (this.isCollapsible) delete require.cache[require.resolve('@civictheme/uikit/components/00-base/collapsible/collapsible')]
if (this.isFlyout) delete require.cache[require.resolve('@civictheme/uikit/components/00-base/flyout/flyout')]
}
},
created() {
mounted() {
this.attachJs()
},
beforeDestroy() {
this.detachJs()
},
watch: {
item(to) {
if (to.children.length) {
this.detachJs()
this.attachJs()
}
}
Expand Down

0 comments on commit 4e3fbf0

Please sign in to comment.