Skip to content

Commit 048c6ac

Browse files
committed
fix: expose featherIcons to Vue prototype
1 parent 58f3870 commit 048c6ac

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/scripts/index.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import featherIcons from 'feather-vue'
2+
13
// plugins
24
import Components from './components'
35

@@ -14,27 +16,38 @@ const mixins = { validatable, resettable }
1416
export const Clair = {
1517
mixins,
1618
install (Vue) {
19+
const VuePrototype = Vue.prototype
20+
const defineReadOnly = function (key, val) {
21+
Object.defineProperty(VuePrototype, key, {
22+
get () {
23+
return val
24+
},
25+
configurable: process.env.NODE_ENV !== 'production',
26+
enumerable: false
27+
})
28+
}
29+
30+
// set a noop utility
31+
defineReadOnly('noop', _ => _)
32+
1733
// inject $clair to Vue prototype
18-
if (!('$clair' in Vue.prototype)) {
34+
if (!('$clair' in VuePrototype)) {
1935
const $clair = new Vue({
2036
data: {
2137
responsive: null,
2238
defaultThrottleTime: 150
2339
}
2440
})
2541
$clair.mixins = mixins
26-
27-
Object.defineProperty(Vue.prototype, '$clair', {
28-
get () {
29-
return $clair
30-
}
31-
})
42+
defineReadOnly('$clair', $clair)
3243
}
3344

34-
Vue.prototype.noop = () => {}
45+
// expose featherIcons for convenience
46+
defineReadOnly('$featherIcons', featherIcons)
3547

3648
// register components
3749
Vue.use(Components)
50+
3851
// install plugins
3952
Vue.use(Modal)
4053
Vue.use(Responsive)

0 commit comments

Comments
 (0)