Skip to content

Reference attach element with 'this' #16253

Open
@mellunar

Description

@mellunar

Describe the problem

The documentation suggests that for Svelte versions >= 5.29 @attach should be used instead of use:.
When whe call a function using use: we can reference the own component with this.
<div use:directive={this, someValue}>content</div>

To have the same result with @attach, we need to call an anonymous arrow function.
<div {@attach directive((element) => element, someValue)}>content</div>

Describe the proposed solution

Allow to reference the own element by using this, removing the need to call an arrow function to accomplish that.
<div {@attach directive(this, someValue)}>content</div>

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting submitterneeds a reproduction, or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions