Skip to content

edge case: Valueless option with async work duplicates (async) work #16683

@elliott-with-the-longest-name-on-github

Description

Describe the bug

<option>{await work()}</option> duplicates the call to work because it injects a synthetic value attribute which just has the copied contents of the child expression. This wasn't a big deal in sync-land but async-land means much bigger duplication consequences. The fix isn't very complicated in practice; we basically "just" need to hoist the expression tag such that the compiled code does this instead:

const promise = work();
<option value={await promise}>{await promise}</option>

Reproduction

https://svelte.dev/playground/hello-world?version=5.38.6#H4sIAAAAAAAAE23MPQuDMBSF4b8S7qKC6B6s0K1j99ohNccSuCZirtoi_vdiP7auL885K3nTgzSdwBzUEka2KoV1AptRTp1jRNKXleQ57G4PlP9Wx2Eo4gyWvd1MxL_eBi_wEklTFcFoRc2GJxzWxIZ7stWNV6oKg7jg69Usxok6j6F3EcWIGHhG-pbZVpVf1viq_HzVjaecBA8hLeOE7ZqTGMeL85Z0ZzhiewHaa9SD5gAAAA==

Logs

System Info

nty

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions