"use strict";

var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = void 0;

var _base = require("../../utils/base");

var _vueNormalizeComponent = _interopRequireDefault(require("../../utils/vue-normalize-component.js"));

/* script */
var __vue_script__ = {
  name: (0, _base.createComponentName)('portal'),
  mixins: [_base.componentMixin],
  props: {
    // 挂载的节点 默认body
    target: {
      //eslint-disable-line
      default: 'body'
    },
    // 外层class
    name: {
      type: String,
      default: ''
    }
  },
  computed: {
    targetEl() {
      if (this.$isServer || !this.target) return;
      if (typeof this.target === 'string') return document.querySelector(this.target);
      return this.target;
    }

  },
  watch: {
    targetEl(el) {
      el.appendChild(this.$el);
    }

  },

  mounted() {
    if (this.targetEl) this.targetEl.appendChild(this.$el);
  },

  destroyed() {
    if (!this.levaeing || !this.name) {
      if (this.$el && this.$el.parentNode) this.$el.parentNode.removeChild(this.$el);
    }
  },

  render() {
    if (this.$slots.default) return this.$slots.default[0];
    return null;
  }

};
/* template */

/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = undefined;
/* module identifier */

var __vue_module_identifier__ = undefined;
/* functional template */

var __vue_is_functional_template__ = undefined;
/* component normalizer */

/* style inject */

/* style inject SSR */
var _default = (0, _vueNormalizeComponent.default)({}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);

exports.default = _default;