Subscribe on changes!

The Render Function supports customizing the order of Attribute Processing and Mount Children.

avatar
Apr 7th 2021

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: image After Patch Change: image

Whether or not configuration items can be provided, the processing order of attributes and children is determined by the customizer.

I have two plans:

  1. Extend RendererOptions, support custom order.
function baseCreateRenderer(
    options: RendererOptions,
    createHydrationFns?: typeof createHydrationFunctions
)
  1. Increase environment variables,support conditional compilation of this module.

What does the proposed API look like?

  1. Extend RendererOptions, support custom order.
// use
baseCreateRenderer({
  ...rendererOptions,
  prefixOrder: true
})
avatar
Apr 7th 2021

Vue2 is the same way.there is a reason why it was designed that way. see https://github.com/vuejs/vue-next/issues/1318

avatar
Apr 7th 2021

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.

avatar
Apr 13th 2021

Because this behavior is the same as vue2, I wonder how weex handles similar problems?