Skip to content

feat: attachments #15000

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

Merged
merged 36 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
531e75d
parse attachments
Rich-Harris Dec 20, 2024
b29e1e3
basic attachments working
Rich-Harris Dec 20, 2024
2329284
working
Rich-Harris Dec 20, 2024
0c914eb
rename to attach
Rich-Harris Dec 20, 2024
1988ba4
fix
Rich-Harris Dec 21, 2024
e1b940c
restrict which symbols are recognised as attachment keys
Rich-Harris Dec 23, 2024
ed3bf01
merge main
Rich-Harris Jan 13, 2025
0690ba2
allow cleanup to be returned directly
Rich-Harris Jan 13, 2025
e0620a1
changeset
Rich-Harris Jan 13, 2025
2ae3aa0
fix
Rich-Harris Jan 13, 2025
7046427
lint
Rich-Harris Jan 14, 2025
85cc9bc
remove createAttachmentKey/isAttachmentKey
Rich-Harris Jan 14, 2025
bec5708
fix spreading of symbol properties onto component
Rich-Harris Jan 14, 2025
afab150
types
Rich-Harris Jan 14, 2025
7e5d4d9
fix
Rich-Harris Jan 14, 2025
c599e90
update name
Rich-Harris Jan 14, 2025
8699771
reserve ability to use sequence expressions in future
Rich-Harris Jan 14, 2025
1664fd8
Update packages/svelte/src/internal/client/dom/elements/attachments.js
Rich-Harris Jan 15, 2025
6402161
actually let's do this instead
Rich-Harris Jan 15, 2025
d09cdf6
expose createAttachmentKey
Rich-Harris May 13, 2025
8239d57
make room for `@attach` docs
Rich-Harris May 13, 2025
df3342f
add docs
Rich-Harris May 13, 2025
a466021
failing test
Rich-Harris May 13, 2025
d6d9f0c
fix
Rich-Harris May 13, 2025
5f7d9dd
lock down
Rich-Harris May 13, 2025
dd8c17a
merge/fix
Rich-Harris May 13, 2025
fe78c1c
add missing reference docs
Rich-Harris May 14, 2025
be46c94
prevent conflicts
Rich-Harris May 14, 2025
f8e6696
update docs
Rich-Harris May 14, 2025
b880f74
regenerate
Rich-Harris May 14, 2025
a7aa1a7
fix link
Rich-Harris May 14, 2025
bd0157a
add Attachment interface
Rich-Harris May 14, 2025
c69c5d7
beef up test
Rich-Harris May 14, 2025
999a05a
regenerate
Rich-Harris May 14, 2025
339ce84
tweak types
Rich-Harris May 14, 2025
8255bc6
fix
Rich-Harris May 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tweak types
  • Loading branch information
Rich-Harris committed May 14, 2025
commit 339ce842b9cd2126fe09267349de66b7929cd227
4 changes: 3 additions & 1 deletion packages/svelte/elements.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8

import type { Attachment } from 'svelte/attachments';

// Note: We also allow `null` as a valid value because Svelte treats this the same as `undefined`

type Booleanish = boolean | 'true' | 'false';
Expand Down Expand Up @@ -862,7 +864,7 @@ export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, D
[key: `data-${string}`]: any;

// allow any attachment
[key: symbol]: (node: T) => void | (() => void);
[key: symbol]: Attachment<T>;
}

export type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | (string & {});
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte/src/attachments/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* It can be attached to an element with an `{@attach ...}` tag, or by spreading an object containing
* a property created with [`createAttachmentKey`](https://svelte.dev/docs/svelte/svelte-attachments#createAttachmentKey).
*/
export interface Attachment {
(element: Element): void | (() => void);
export interface Attachment<T extends EventTarget = Element> {
(element: T): void | (() => void);
}

export * from './index.js';
4 changes: 2 additions & 2 deletions packages/svelte/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,8 @@ declare module 'svelte/attachments' {
* It can be attached to an element with an `{@attach ...}` tag, or by spreading an object containing
* a property created with [`createAttachmentKey`](https://svelte.dev/docs/svelte/svelte-attachments#createAttachmentKey).
*/
export interface Attachment {
(element: Element): void | (() => void);
export interface Attachment<T extends EventTarget = Element> {
(element: T): void | (() => void);
}
/**
* Creates an object key that will be recognised as an attachment when the object is spread onto an element,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy