UNPKG

vue-simple-portal

Version:
3 lines (2 loc) • 1.05 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):t.SimplePortal=e(t.Vue)}(this,function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;return{name:"simple-portal",props:{target:{type:String,required:!0},componentName:{type:String,default:"portal-target"}},mounted:function(){var e=this.$vnode.data,i=e.staticClass,s=e.class,n=e.attrs,l=this.$slots.default;this.targetEl=document.getElementById(this.target),this.childEl=document.createElement("div"),this.childEl.id=this.componentName,this.targetEl.appendChild(this.childEl),this.childVm=new t({name:this.componentName,abstract:!0,parent:this,render:function(t){return t("div",{staticClass:i,class:s,attrs:n},l)}}),this.childVm.$mount(this.childEl),this.childEl=this.childVm.$el},beforeDestroy:function(){this.childVm.$destroy(),this.targetEl.removeChild(this.childEl)},render:function(){return this.$slots.placeholder}}}); //# sourceMappingURL=vue-simple-portal.min.js.map