Skip to content

Commit

Permalink
fix: expose featherIcons to Vue prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusFu committed Dec 7, 2018
1 parent 58f3870 commit 048c6ac
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/scripts/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import featherIcons from 'feather-vue'

// plugins
import Components from './components'

Expand All @@ -14,27 +16,38 @@ const mixins = { validatable, resettable }
export const Clair = {
mixins,
install (Vue) {
const VuePrototype = Vue.prototype
const defineReadOnly = function (key, val) {
Object.defineProperty(VuePrototype, key, {
get () {
return val
},
configurable: process.env.NODE_ENV !== 'production',
enumerable: false
})
}

// set a noop utility
defineReadOnly('noop', _ => _)

// inject $clair to Vue prototype
if (!('$clair' in Vue.prototype)) {
if (!('$clair' in VuePrototype)) {
const $clair = new Vue({
data: {
responsive: null,
defaultThrottleTime: 150
}
})
$clair.mixins = mixins

Object.defineProperty(Vue.prototype, '$clair', {
get () {
return $clair
}
})
defineReadOnly('$clair', $clair)
}

Vue.prototype.noop = () => {}
// expose featherIcons for convenience
defineReadOnly('$featherIcons', featherIcons)

// register components
Vue.use(Components)

// install plugins
Vue.use(Modal)
Vue.use(Responsive)
Expand Down

0 comments on commit 048c6ac

Please sign in to comment.