"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.inherit = inherit; exports.emit = emit; exports.mount = mount; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _vue = _interopRequireDefault(require("vue")); var inheritKey = ['ref', 'key', 'style', 'class', 'attrs', 'refInFor', 'nativeOn', 'directives', 'staticClass', 'staticStyle']; var mapInheritKey = { nativeOn: 'on' }; // inherit partial context, map nativeOn to on function inherit(context, inheritListeners) { var result = inheritKey.reduce(function (obj, key) { if (context.data[key]) { obj[mapInheritKey[key] || key] = context.data[key]; } return obj; }, {}); if (inheritListeners) { result.on = result.on || {}; (0, _extends2.default)(result.on, context.data.on); } return result; } // emit event function emit(context, eventName) { for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } var listeners = context.listeners[eventName]; if (listeners) { if (Array.isArray(listeners)) { listeners.forEach(function (listener) { listener.apply(void 0, args); }); } else { listeners.apply(void 0, args); } } } // mount functional component function mount(Component, data) { var instance = new _vue.default({ el: document.createElement('div'), props: Component.props, render: function render(h) { return h(Component, (0, _extends2.default)({ props: this.$props }, data)); } }); document.body.appendChild(instance.$el); return instance; }