How to use the @material/list.MDCList.attachTo function in @material/list

To help you get started, we’ve selected a few @material/list examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matsp / material-components-vue / components / list / List.vue View on Github external
reInstantiateList () {
      if (this.js) {
        if (this.mdcList) {
          this.mdcList.destroy()
        }
        MDCList.attachTo(this.$el)
        this.mdcList.singleSelection = this.singleSelection
        this.mdcList.vertical = this.vertical
        this.mdcList.selectedIndex = this.selectedIndex
        this.mdcList.wrapFocus = this.wrapFocus
      } else {
        if (this.mdcList) {
          this.mdcList.destroy()
        }
        this.mdcList = undefined
      }
    },
    updateSlot () {
github matsp / material-components-vue / components / list / List.vue View on Github external
this.$nextTick(() => {
      if (this.js && !this.mdcList) {
        this.mdcList = MDCList.attachTo(this.$el)
        this.mdcList.singleSelection = this.singleSelection
        if (this.singleSelection) this.$el.setAttribute('role', 'listbox')
        this.mdcList.vertical = this.vertical
        if ((this.selectedIndex instanceof Number && this.selectedIndex > -1) || this.selectedIndex instanceof Array) this.mdcList.selectedIndex = this.selectedIndex
        this.mdcList.wrapFocus = this.wrapFocus

        this.slotObserver = new MutationObserver(() => this.updateSlot())
        this.slotObserver.observe(this.$el, {
          childList: true,
          subtree: true
        })
      }
    })
  },