Skip to content

Render function allow force set as attribute instead of property #3792

Closed
@Giwayume

Description

@Giwayume

What problem does this feature solve?

The decision to merge the vnode structure together in Vue 3 render functions has become kind of a pain in the butt for me, because it takes away the ability to explicitly specify a prop as an attribute that should show in the DOM.

https://v3.vuejs.org/guide/migration/render-function-api.html#_3-x-syntax-3

It is necessary in many cases for attributes to be shown in the DOM structure for styling and querying purposes, and not just be set as html element properties that are invisible to DOM querying.

If I'm using Vue on top of web components (window.customElements), it's ultimately up to whether or not that component has the prop defined on the HTML element instance, which means properties like "id", "name" don't show up in the DOM because of this line:

https://github.com/vuejs/vue-next/blob/bd3cc4d2c79454736908433b607b1e1323bea67a/packages/runtime-dom/src/patchProp.ts#L117

How are we supposed to force something to be set as an attribute instead of a property on an HTML element in Vue 3?

What does the proposed API look like?

I'm not sure how the current decision to merge the definition together in render functions can be fixed to force properties to be added as HTML attributes. If there already is a capability to do this in Vue 3, I totally missed it. The only thing I can think of is have a app.config setting that's a map of HTML element names to properties that should always be attributes and reference that in the render function implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✨ feature requestNew feature or requesthas workaroundA workaround has been found to avoid the problemneed more infoFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions