visma-meglerfront / sweet-modal-vue

The sweetest library to happen to modals.
Other
757 stars 85 forks source link

Installing component via Vue.use causes error in old browsers #79

Open gamtiq opened 5 years ago

gamtiq commented 5 years ago

If I install component via Vue.use and don't add it to transpileDependencies option of Vue CLI, I get the following error on browsers that don't support Enhanced Object Literals:

Uncaught SyntaxError: Unexpected token (

The error arises because of the following code in src/plugin.js:

export default {
    install(Vue, options) {
        Vue.component('SweetModal', SweetModal)
        Vue.component('SweetModalTab', SweetModalTab)
    }
}

To fix the issue it is necessary change line #4 to:

install: function install(Vue, options) {

To work around the issue, install components by calling Vue.component:

import { SweetModal, SweetModalTab } from 'sweet-modal-vue';
...
Vue.component('SweetModal', SweetModal);
Vue.component('SweetModalTab', SweetModalTab);