{"version":3,"file":"v-runtime-template.js","sources":["../index.js"],"sourcesContent":["const defineDescriptor = (src, dest, name) => {\n if (!dest.hasOwnProperty(name)) {\n const descriptor = Object.getOwnPropertyDescriptor(src, name);\n Object.defineProperty(dest, name, descriptor);\n }\n};\n\nconst merge = objs => {\n const res = {};\n objs.forEach(obj => {\n obj &&\n Object.getOwnPropertyNames(obj).forEach(name =>\n defineDescriptor(obj, res, name)\n );\n });\n return res;\n};\n\nconst buildFromProps = (obj, props) => {\n const res = {};\n props.forEach(prop => defineDescriptor(obj, res, prop));\n return res;\n};\n\nexport default {\n props: {\n template: String,\n parent: Object,\n templateProps: {\n type: Object,\n default: () => ({})\n }\n },\n render(h) {\n if (this.template) {\n const parent = this.parent || this.$parent\n const {\n $data: parentData = {},\n $props: parentProps = {},\n $options: parentOptions = {}\n } = parent;\n const {\n components: parentComponents = {},\n computed: parentComputed = {},\n methods: parentMethods = {}\n } = parentOptions;\n const {\n $data = {},\n $props = {},\n $options: { methods = {}, computed = {}, components = {} } = {}\n } = this;\n const passthrough = {\n $data: {},\n $props: {},\n $options: {},\n components: {},\n computed: {},\n methods: {}\n };\n\n //build new objects by removing keys if already exists (e.g. created by mixins)\n Object.keys(parentData).forEach(e => {\n if (typeof $data[e] === \"undefined\")\n passthrough.$data[e] = parentData[e];\n });\n Object.keys(parentProps).forEach(e => {\n if (typeof $props[e] === \"undefined\")\n passthrough.$props[e] = parentProps[e];\n });\n Object.keys(parentMethods).forEach(e => {\n if (typeof methods[e] === \"undefined\")\n passthrough.methods[e] = parentMethods[e];\n });\n Object.keys(parentComputed).forEach(e => {\n if (typeof computed[e] === \"undefined\")\n passthrough.computed[e] = parentComputed[e];\n });\n Object.keys(parentComponents).forEach(e => {\n if (typeof components[e] === \"undefined\")\n passthrough.components[e] = parentComponents[e];\n });\n\n const methodKeys = Object.keys(passthrough.methods || {});\n const dataKeys = Object.keys(passthrough.$data || {});\n const propKeys = Object.keys(passthrough.$props || {});\n const templatePropKeys = Object.keys(this.templateProps);\n const allKeys = dataKeys.concat(propKeys).concat(methodKeys).concat(templatePropKeys);\n const methodsFromProps = buildFromProps(parent, methodKeys);\n const finalProps = merge([\n passthrough.$data,\n passthrough.$props,\n methodsFromProps,\n this.templateProps\n ]);\n const provide = this.$parent._provided;\n\n const dynamic = {\n template: this.template || \"
\",\n props: allKeys,\n computed: passthrough.computed,\n components: passthrough.components,\n provide: provide\n };\n\n return h(dynamic, { props: finalProps });\n }\n }\n};\n"],"names":["const","defineDescriptor","src","dest","name","hasOwnProperty","descriptor","Object","getOwnPropertyDescriptor","defineProperty","props","template","String","parent","templateProps","type","default","render","h","this","$parent","passthrough","$data","$props","$options","components","computed","methods","keys","parentData","forEach","e","parentProps","parentMethods","parentComputed","parentComponents","methodKeys","dataKeys","propKeys","templatePropKeys","allKeys","concat","methodsFromProps","obj","res","prop","finalProps","objs","getOwnPropertyNames","merge","provide","_provided"],"mappings":"AAAAA,IAAMC,WAAoBC,EAAKC,EAAMC,OAC9BD,EAAKE,eAAeD,GAAO,KACxBE,EAAaC,OAAOC,yBAAyBN,EAAKE,GACxDG,OAAOE,eAAeN,EAAMC,EAAME,OAqBvB,CACbI,MAAO,CACLC,SAAUC,OACVC,OAAQN,OACRO,cAAe,CACbC,KAAMR,OACNS,+BAGJC,gBAAOC,MACDC,KAAKR,SAAU,KACXE,EAASM,KAAKN,QAAUM,KAAKC,iCAEb,kCACE,oCACI,sCAGK,oCACJ,mCACF,UAMvBD,0BAHM,UAGNA,2BAFO,UAEPA,6BAD2D,IAAnD,+BAAY,oCAAe,sCAAiB,QAElDE,EAAc,CAClBC,MAAO,GACPC,OAAQ,GACRC,SAAU,GACVC,WAAY,GACZC,SAAU,GACVC,QAAS,IAIXpB,OAAOqB,KAAKC,GAAYC,iBAAQC,QACN,IAAbT,EAAMS,KACfV,EAAYC,MAAMS,GAAKF,EAAWE,MAEtCxB,OAAOqB,KAAKI,GAAaF,iBAAQC,QACN,IAAdR,EAAOQ,KAChBV,EAAYE,O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