@linusborg/vue-simple-portal
Advanced tools
Comparing version 0.1.1 to 0.1.2
/** | ||
* vue-simple-portal | ||
* version: 0.1.1, | ||
* version: 0.1.2, | ||
* (c) Thorsten Lünborg, 2019 | ||
@@ -162,3 +162,3 @@ * LICENCE: Apache-2.0 | ||
var child = document.createElement(this.tag); | ||
child.id = config.selector; | ||
child.id = this.selector.substring(1); | ||
parent.append(child); | ||
@@ -165,0 +165,0 @@ }, |
/** | ||
* vue-simple-portal | ||
* version: 0.1.1, | ||
* version: 0.1.2, | ||
* (c) Thorsten Lünborg, 2019 | ||
@@ -9,3 +9,3 @@ * LICENCE: Apache-2.0 | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e=e||self).VueSimplePortal={},e.Vue)}(this,function(e,t){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}t=t&&t.hasOwnProperty("default")?t.default:t;var o={selector:"vue-portal-target-".concat(function(e){e=e||21;for(var t="";0<e--;)t+="bjectSymhasOwnProp-0123456789ABCDEFGHIJKLMNQRTUVWXYZ_dfgiklquvxz"[64*Math.random()|0];return t}())},r=function(e){return o.selector=e},i="undefined"!=typeof window&&void 0!==("undefined"==typeof document?"undefined":n(document)),d=t.extend({abstract:!0,name:"PortalOutlet",props:["nodes","tag"],data:function(e){return{updatedNodes:e.nodes}},render:function(e){var t=this.updatedNodes&&this.updatedNodes();return t?t.length<2&&!t[0].text?t:e(this.tag||"DIV",t):e()},destroyed:function(){var e=this.$el;e.parentNode.removeChild(e)}}),u=t.extend({name:"VueSimplePortal",props:{disabled:{type:Boolean},prepend:{type:Boolean},selector:{type:String,default:function(){return"#".concat(o.selector)}},tag:{type:String,default:"DIV"}},render:function(e){if(this.disabled){var t=this.$scopedSlots&&this.$scopedSlots.default();return t?t.length<2&&!t[0].text?t:e(this.tag,t):e()}return e()},created:function(){this.getTargetEl()||this.insertTargetEl()},updated:function(){var e=this;this.$nextTick(function(){e.disabled||e.slotFn===e.$scopedSlots.default||(e.container.updatedNodes=e.$scopedSlots.default),e.slotFn=e.$scopedSlots.default})},beforeDestroy:function(){this.unmount()},watch:{disabled:{immediate:!0,handler:function(e){e?this.unmount():this.$nextTick(this.mount)}}},methods:{getTargetEl:function(){if(i)return document.querySelector(this.selector)},insertTargetEl:function(){if(i){var e=document.querySelector("body"),t=document.createElement(this.tag);t.id=o.selector,e.append(t)}},mount:function(){var e=this.getTargetEl(),t=document.createElement("DIV");this.prepend&&e.firstChild?e.insertBefore(t,e.firstChild):e.append(t),this.container=new d({el:t,parent:this,propsData:{tag:this.tag,nodes:this.$scopedSlots.default}})},unmount:function(){this.container&&(this.container.$destroy(),delete this.container)}}});function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.component(t.name||"portal",u),t.defaultSelector&&r(t.defaultSelector)}"undefined"!=typeof window&&window.Vue&&window.Vue===t&&t.use(s),e.Portal=u,e.config=o,e.default=s,e.setSelector=r,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e=e||self).VueSimplePortal={},e.Vue)}(this,function(e,t){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}t=t&&t.hasOwnProperty("default")?t.default:t;var o={selector:"vue-portal-target-".concat(function(e){e=e||21;for(var t="";0<e--;)t+="bjectSymhasOwnProp-0123456789ABCDEFGHIJKLMNQRTUVWXYZ_dfgiklquvxz"[64*Math.random()|0];return t}())},r=function(e){return o.selector=e},i="undefined"!=typeof window&&void 0!==("undefined"==typeof document?"undefined":n(document)),d=t.extend({abstract:!0,name:"PortalOutlet",props:["nodes","tag"],data:function(e){return{updatedNodes:e.nodes}},render:function(e){var t=this.updatedNodes&&this.updatedNodes();return t?t.length<2&&!t[0].text?t:e(this.tag||"DIV",t):e()},destroyed:function(){var e=this.$el;e.parentNode.removeChild(e)}}),u=t.extend({name:"VueSimplePortal",props:{disabled:{type:Boolean},prepend:{type:Boolean},selector:{type:String,default:function(){return"#".concat(o.selector)}},tag:{type:String,default:"DIV"}},render:function(e){if(this.disabled){var t=this.$scopedSlots&&this.$scopedSlots.default();return t?t.length<2&&!t[0].text?t:e(this.tag,t):e()}return e()},created:function(){this.getTargetEl()||this.insertTargetEl()},updated:function(){var e=this;this.$nextTick(function(){e.disabled||e.slotFn===e.$scopedSlots.default||(e.container.updatedNodes=e.$scopedSlots.default),e.slotFn=e.$scopedSlots.default})},beforeDestroy:function(){this.unmount()},watch:{disabled:{immediate:!0,handler:function(e){e?this.unmount():this.$nextTick(this.mount)}}},methods:{getTargetEl:function(){if(i)return document.querySelector(this.selector)},insertTargetEl:function(){if(i){var e=document.querySelector("body"),t=document.createElement(this.tag);t.id=this.selector.substring(1),e.append(t)}},mount:function(){var e=this.getTargetEl(),t=document.createElement("DIV");this.prepend&&e.firstChild?e.insertBefore(t,e.firstChild):e.append(t),this.container=new d({el:t,parent:this,propsData:{tag:this.tag,nodes:this.$scopedSlots.default}})},unmount:function(){this.container&&(this.container.$destroy(),delete this.container)}}});function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.component(t.name||"portal",u),t.defaultSelector&&r(t.defaultSelector)}"undefined"!=typeof window&&window.Vue&&window.Vue===t&&t.use(s),e.Portal=u,e.config=o,e.default=s,e.setSelector=r,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "@linusborg/vue-simple-portal", | ||
"description": "A simple Portal implementation for Vue, to mount slot content to another element", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Thorsten Lünborg", |
@@ -22,6 +22,6 @@ # vue-simple-portal | ||
<body> | ||
<script src="https://unkpg.com/vue/dist/vue.js"></script> | ||
<script src="https://unkpg.com/@linusborg/vue-simple-portal"></script> | ||
<script src="https://unpkg.com/vue/dist/vue.js"></script> | ||
<script src="https://unpkg.com/@linusborg/vue-simple-portal"></script> | ||
<div id="app"> | ||
<-- your Vue app mounts to this element --> | ||
<!-- your Vue app mounts to this element --> | ||
</div> | ||
@@ -57,5 +57,5 @@ | ||
Well, `portal-vue` was my first sucessful library, and I wanted it to be _awesome_, so I packed it full of features to portal _anything_ to _anywhere_, _anytime_ you want. | ||
Well, `portal-vue` was my first successful library, and I wanted it to be _awesome_, so I packed it full of features to portal _anything_ to _anywhere_, _anytime_ you want. | ||
That' turned out pretty well, but there were two issues that I found over time, so I wrote a smaller lib that adresses these issues while sliming down on features and (= bundle size) in order to concentrate on the main use case. | ||
That turned out pretty well, but also means the library is not exactly *tiny* anymore, and there also were a few issues that I found over time, so I wrote a smaller lib that adresses these issues while sliming down on features and (= bundle size) in order to concentrate on the main use case. | ||
@@ -131,4 +131,4 @@ <details> | ||
<head> | ||
<script src="https://unkpg.com/vue/dist/vue.js"></script> | ||
<script src="https://unkpg.com/vue-simple-portal"></script> | ||
<script src="https://unpkg.com/vue/dist/vue.js"></script> | ||
<script src="https://unpkg.com/vue-simple-portal"></script> | ||
</head> | ||
@@ -135,0 +135,0 @@ ``` |
@@ -74,3 +74,3 @@ import Vue from 'vue'; | ||
var child = document.createElement(this.tag); | ||
child.id = config.selector; | ||
child.id = this.selector.substring(1); | ||
parent.append(child); | ||
@@ -77,0 +77,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
38413