Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
duanlikang opened this issue Apr 7, 2021 · 3 comments

Comments

@duanlikang
Copy link

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
})
@edison1105
Copy link
Member

edison1105 commented Apr 7, 2021

Vue2 is the same way.there is a reason why it was designed that way.
see #1318

@duanlikang
Copy link
Author

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.

@HcySunYang
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants