UNPKG

vue-router-multi-view

Version:
2 lines (1 loc) 4.95 kB
var VueRouterMultiView=function(e){"use strict";function n(e,n,r){if(n)for(var o=n;o=o.$parent;){var i=o.$options.errorCaptured;if(i)for(var a=0;a<i.length;a++)try{if(!1===i[a].call(o,e,n,r))return}catch(e){t(e,o,"errorCaptured hook")}}t(e,n,r)}function t(n,t,o){if(e.Vue.config.errorHandler)try{return e.Vue.config.errorHandler.call(null,n,t,o)}catch(e){r(e,null,"config.errorHandler")}r(n,t,o)}function r(n,t,r){if("production"!==process.env.NODE_ENV&&function(n,t){e.Vue.config.warnHandler?e.Vue.config.warnHandler.call(null,n,t,""):l&&!e.Vue.config.silent&&console.error("[Vue warn]: "+n)}("Error in "+r+': "'+n.toString()+'"',t),!l)throw n;console.error(n)}function o(e){for(;e&&(e=e.$parent);)if(e._inactive)return!0;return!1}function i(e,n){if(n){if(e._directInactive=!1,o(e))return}else if(e._directInactive)return;if(e._inactive||null===e._inactive){e._inactive=!1;for(var t=0;t<e.$children.length;t++)i(e.$children[t]);c(e,"activated")}}function a(e,n){if(!(n&&(e._directInactive=!0,o(e))||e._inactive)){e._inactive=!0;for(var t=0;t<e.$children.length;t++)a(e.$children[t]);c(e,"deactivated")}}function c(e,t){var r=e.$options[t];if(r)for(var o=0,i=r.length;o<i;o++)try{r[o].call(e)}catch(r){n(r,e,t+" hook")}e._hasHookEvent&&e.$emit("hook:"+t)}function u(e,n){switch(void 0===n?"undefined":s(n)){case"undefined":return;case"object":return n;case"function":return n(e);case"boolean":return n?e.params:void 0;default:"production"!==process.env.NODE_ENV&&function(e,n){"production"===process.env.NODE_ENV||e||"undefined"!=typeof console&&console.warn("[vue-router] "+n)}(!1,"props in '"+e.path+"' is a "+(void 0===n?"undefined":s(n))+", expecting an object, function or boolean.")}}function f(n){f.installed||(f.installed=!0,e.Vue=n,e.Vue.component("router-multi-view",v))}var l="undefined"!=typeof console,s="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},p=(function(){function e(e){this.value=e}function n(n){function t(o,i){try{var a=n[o](i),c=a.value;c instanceof e?Promise.resolve(c.value).then(function(e){t("next",e)},function(e){t("throw",e)}):r(a.done?"return":"normal",a.value)}catch(e){r("throw",e)}}function r(e,n){switch(e){case"return":o.resolve({value:n,done:!0});break;case"throw":o.reject(n);break;default:o.resolve({value:n,done:!1})}(o=o.next)?t(o.key,o.arg):i=null}var o,i;this._invoke=function(e,n){return new Promise(function(r,a){var c={key:e,arg:n,resolve:r,reject:a,next:null};i?i=i.next=c:(o=i=c,t(e,n))})},"function"!=typeof n.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(n.prototype[Symbol.asyncIterator]=function(){return this}),n.prototype.next=function(e){return this._invoke("next",e)},n.prototype.throw=function(e){return this._invoke("throw",e)},n.prototype.return=function(e){return this._invoke("return",e)}}(),Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}),v={name:"RouterView",functional:!0,props:{viewName:{type:String,default:"default"},morph:{type:[String,Object,Function],default:"div"}},render:function(e,n){for(var t=n.props,r=n.parent,o=n.data,c=n.children,f=r.$createElement,l=t.viewName,s=r.$route,v=r._routerViewCache||(r._routerViewCache={}),d=0,h=!1;r&&r._routerRoot!==r;)r.$vnode&&r.$vnode.data.routerView&&d++,r._inactive&&(h=!0),r=r.$parent;var y=d,m=null,w=s.matched[d];if(w){var g=w.path,V=v[g]||(v[g]={});if(h)m=V[l];else{var b=V[l]||(V[l]={component:null,data:{},name:w.name,active:void 0});m=b,b.component=w.components[l]}}var _=[];return Object.keys(v).forEach(function(e){var n=v[e][l];if(n&&n.component){var t=n===m,r=p({},n.data,{routerView:!0,routerViewDepth:y,key:e,attrs:{"data-route-path":e,"data-route-name":n.name,"data-is-active":!!t||null},keepAlive:!0,directives:[{name:"show",value:t}]});if(t){var o=s.matched[d];r.registerRouteInstance=function(e,n){var t=o.instances[l];(n&&t!==e||!n&&t===e)&&(o.instances[l]=n)};var c=r.props=u(s,o.props&&o.props[l]);if(c){c=r.props=function(e,n){for(var t in n)e[t]=n[t];return e}({},c);var h=r.attrs=r.attrs||{};for(var g in c)n.component.props&&g in n.component.props||(h[g]=c[g],delete c[g])}}var V=p({},r.hook||{});r.hook=V;var b=V.prepatch,k=function(e,r){b&&b(e,r),t&&(w.instances[l]=r.componentInstance),function(e,n,t){n.active!==e&&(t&&(e?i(t,!0):a(t,!0),t._inactive=!e),n.active=e)}(t,n,r.componentInstance)};V.prepatch=k,n.data=r,_.push(f(n.component,r))}}),c&&_.push.apply(_,function(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}(c)),f(t.morph,o,_)}};e.Vue=void 0;var d=v,h={install:f},y=null;return"undefined"!=typeof window?y=window.Vue:"undefined"!=typeof global&&(y=global.Vue),y&&y.use(h),e.install=f,e.RouterMultiView=d,e.default=h,e}({});