Skip to content

Allow shorthand for directives like lwc:ref #3303

Open
@AllanOricil

Description

Is your feature request related to a problem? Please describe.

no, I just would like to know if it could be simplified. And nice feature, by the way. We can get rid of data-id parameters in our templates.

https://developer.salesforce.com/blogs/2023/01/lwc-enhancements-for-developers-learn-moar-spring-23
image

Is there a reason for prepending "ref" with the word "lwc:" ?

Couldn't it just be

<div :ref="reference"></div>
<div ref="reference"></div>

Vue and React template engines are able to use just "ref", so I believe lwc would also be able to do it. It would be good if you could try to follow what other frameworks did well, so that people that are used to one of them can learn lwc faster. I only see benefits doing so.

Another question, does it accept expressions?

Like,

<div ref={dynamicRef}></div>
<template for:each={bla} for:item="blas">
    <div ref={bla}></div>
</template>
<template for:each={bla} for:item="blas">
     <div ref={getDynamicRef(bla)}></div>
</template>

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions