Is it possible to convert a living component instance back to a template?
Currently, I am working on a form-making website with element-ui and Vue.js. I have finished the <preview /> component. It will present the editing result to the user, and now I need to export the whole result form as a Vue.js template.
Since the resulting form is simply made up of a whole bunch of element-ui form input components, like <el-input>, <el-button>, it might be possible to convert this component back to template.
But soon I realized it is not as simple as I thought. I tried doing this by traversing the virtual dom tree but ended up discovering that Vue.js doesn't offer a public API for traversing vnodes. There is an instance attribute named $vnode, but it is the the placeholder node for the component in parent's render tree, according to the code comment. Besides, its children property is undefined. This means I cannot access the children vnodes, thus it becomes impossible to traverse the virtual DOM tree.
Another way is to use the private property _vnode, it is a feasible way though, but the property is private and I'd rather not touch it unless I have no other way.
Another problem I realized later, is that the vdom tree doesn't keep the information about v-if. Once the current true branch is in the virtual DOM tree, and I cannot get other false/invisible tags from the vdom tree.
So it looks like traversing the DOM tree cannot convert an instance back to a template (or maybe I am wrong). Is it some other way that can accomplish my goal?