/*! bxs-vue-ui v3.3.0 */
'use strict';

var normalizeComponent = require('./normalize-component.js');

var Emitter = {
  methods: {
    dispatch: function dispatch(componentName, eventName, params) {
      var parent = this.$parent || this.$root;
      var name = parent.$options.name;

      while (parent && (!name || name !== componentName)) {
        parent = parent.$parent;

        if (parent) {
          name = parent.$options.name;
        }
      }

      if (parent) {
        var _parent, _context;

        (_parent = parent).$emit.apply(_parent, normalizeComponent._concatInstanceProperty(_context = [eventName]).call(_context, params));
      }
    }
  }
};

exports.Emitter = Emitter;
