1 1
import OurVue, { VueConstructor } from 'vue'
2
import { VuetifyUseOptions } from 'vuetify/types'
3 1
import { consoleError } from './util/console'
4

5 1
export function install (Vue: VueConstructor, args: VuetifyUseOptions = {}) {
6 1
  if ((install as any).installed) return
7 0
  (install as any).installed = true
8

9 1
  if (OurVue !== Vue) {
10 0
    consoleError('Multiple instances of Vue detected\nSee https://github.com/vuetifyjs/vuetify/issues/4068\n\nIf you\'re seeing "$attrs is readonly", it\'s caused by this')
11
  }
12

13 1
  const components = args.components || {}
14 1
  const directives = args.directives || {}
15

16 0
  for (const name in directives) {
17 0
    const directive = directives[name]
18

19 0
    Vue.directive(name, directive)
20
  }
21

22 0
  (function registerComponents (components: any) {
23 1
    if (components) {
24 0
      for (const key in components) {
25 0
        const component = components[key]
26 1
        if (component && !registerComponents(component.$_vuetify_subcomponents)) {
27 0
          Vue.component(key, component as typeof Vue)
28
        }
29
      }
30 0
      return true
31
    }
32 0
    return false
33
  })(components)
34

35
  // Used to avoid multiple mixins being setup
36
  // when in dev mode and hot module reload
37
  // https://github.com/vuejs/vue/issues/5089#issuecomment-284260111
38 1
  if (Vue.$_vuetify_installed) return
39 0
  Vue.$_vuetify_installed = true
40

41 0
  Vue.mixin({
42 0
    beforeCreate () {
43 0
      const options = this.$options as any
44

45 1
      if (options.vuetify) {
46 0
        options.vuetify.init(this, this.$ssrContext)
47 0
        this.$vuetify = Vue.observable(options.vuetify.framework)
48
      } else {
49 1
        this.$vuetify = (options.parent && options.parent.$vuetify) || this
50
      }
51
    },
52 0
    beforeMount () {
53
      // @ts-ignore
54 1
      if (this.$options.vuetify && this.$el && this.$el.hasAttribute('data-server-rendered')) {
55
        // @ts-ignore
56 0
        this.$vuetify.isHydrating = true
57
        // @ts-ignore
58 0
        this.$vuetify.breakpoint.update(true)
59
      }
60
    },
61 0
    mounted () {
62
      // @ts-ignore
63 1
      if (this.$options.vuetify && this.$vuetify.isHydrating) {
64
        // @ts-ignore
65 0
        this.$vuetify.isHydrating = false
66
        // @ts-ignore
67 0
        this.$vuetify.breakpoint.update()
68
      }
69
    },
70
  })
71
}

Read our documentation on viewing source code .

Loading