debian-mirror-gitlab/spec/javascripts/helpers/vue_mount_component_helper.js

39 lines
898 B
JavaScript
Raw Normal View History

2018-11-20 20:47:30 +05:30
import Vue from 'vue';
2018-11-08 19:23:39 +05:30
const mountComponent = (Component, props = {}, el = null) =>
new Component({
propsData: props,
}).$mount(el);
export const createComponentWithStore = (Component, store, propsData = {}) =>
new Component({
store,
propsData,
});
2018-03-17 18:26:18 +05:30
2018-05-09 12:01:36 +05:30
export const mountComponentWithStore = (Component, { el, props, store }) =>
new Component({
store,
2018-11-08 19:23:39 +05:30
propsData: props || {},
2018-05-09 12:01:36 +05:30
}).$mount(el);
2018-11-18 11:00:15 +05:30
export const mountComponentWithSlots = (Component, { props, slots }) => {
const component = new Component({
propsData: props || {},
});
component.$slots = slots;
return component.$mount();
};
2018-11-20 20:47:30 +05:30
/**
* Mount a component with the given render method.
*
* This helps with inserting slots that need to be compiled.
*/
export const mountComponentWithRender = (render, el = null) =>
mountComponent(Vue.extend({ render }), {}, el);
2018-11-08 19:23:39 +05:30
export default mountComponent;