The Render Function supports customizing the order of Attribute Processing and Mount Children.
What problem does this feature solve?
I used Vue3 and customized the renderer of Hummer (a cross-end framework similar to Weex). In my business scenario, when element attributes are processed, the attribute value of the parent element is relied on, that is, the child element needs to be processed after the parent element attribute is processed.
For example, in the processing of Class, if I want to implement style inheritance, I need to get the attributes of the current parent element when processing the style of the child element. However, due to the existing Vue next render "mount children first, since some props may rely on child content." design, I had to install a patch package.
The Source Code: After Patch Change:
Whether or not configuration items can be provided, the processing order of attributes and children is determined by the customizer.
I have two plans:
- Extend RendererOptions, support custom order.
function baseCreateRenderer(
options: RendererOptions,
createHydrationFns?: typeof createHydrationFunctions
)
- Increase environment variables,support conditional compilation of this module.
What does the proposed API look like?
- Extend RendererOptions, support custom order.
// use
baseCreateRenderer({
...rendererOptions,
prefixOrder: true
})
Vue2 is the same way.there is a reason why it was designed that way. see https://github.com/vuejs/vue-next/issues/1318
Thank you for your reply. I can understand why it is designed this way. I want to consult if there is a better solution for scenarios that depend on the order of attribute processing. Now I just added a patch package for runtime-core.