Skip to content

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

Open
@duanlikang

Description

@duanlikang

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
})

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions