Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
feat(grid-list): Use MutationObserver for reactive slot updates (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
matsp committed Apr 23, 2018
1 parent 3668145 commit 36f83b1
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions components/grid-list/GridListTile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,38 @@ export default {
default: ''
}
},
mounted () {
if (this.$slots.supporttext) {
this.$slots.supporttext.map(n =>
n.elm.classList.add('mdc-grid-tile__support-text')
)
data () {
return {
slotOberserver: null
}
},
mounted () {
this.updateSlots()
this.slotOberserver = new MutationObserver( () => this.updateSlots())
this.slotOberserver.observe(this.$el, {
childList: true,
subtree: true
})
},
methods: {
updateSlots () {
if (this.$slots.supporttext) {
this.$slots.supporttext.map(n =>
n.elm.classList.add('mdc-grid-tile__support-text')
)
}
if (this.$slots.icon) {
this.$slots.icon.map(n => {
n.elm.classList.add('mdc-grid-tile__icon')
})
}
if (this.$slots.icon) {
this.$slots.icon.map(n => {
n.elm.classList.add('mdc-grid-tile__icon')
})
}
if (this.$slots.primary) {
this.$slots.primary.map(n =>
n.elm.classList.add('mdc-grid-tile__primary-content')
)
if (this.$slots.primary) {
this.$slots.primary.map(n =>
n.elm.classList.add('mdc-grid-tile__primary-content')
)
}
}
}
}
Expand Down

0 comments on commit 36f83b1

Please sign in to comment.