-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
feat: attachments #15000
Changes from 17 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
531e75d
parse attachments
Rich-Harris b29e1e3
basic attachments working
Rich-Harris 2329284
working
Rich-Harris 0c914eb
rename to attach
Rich-Harris 1988ba4
fix
Rich-Harris e1b940c
restrict which symbols are recognised as attachment keys
Rich-Harris ed3bf01
merge main
Rich-Harris 0690ba2
allow cleanup to be returned directly
Rich-Harris e0620a1
changeset
Rich-Harris 2ae3aa0
fix
Rich-Harris 7046427
lint
Rich-Harris 85cc9bc
remove createAttachmentKey/isAttachmentKey
Rich-Harris bec5708
fix spreading of symbol properties onto component
Rich-Harris afab150
types
Rich-Harris 7e5d4d9
fix
Rich-Harris c599e90
update name
Rich-Harris 8699771
reserve ability to use sequence expressions in future
Rich-Harris 1664fd8
Update packages/svelte/src/internal/client/dom/elements/attachments.js
Rich-Harris 6402161
actually let's do this instead
Rich-Harris d09cdf6
expose createAttachmentKey
Rich-Harris 8239d57
make room for `@attach` docs
Rich-Harris df3342f
add docs
Rich-Harris a466021
failing test
Rich-Harris d6d9f0c
fix
Rich-Harris 5f7d9dd
lock down
Rich-Harris dd8c17a
merge/fix
Rich-Harris fe78c1c
add missing reference docs
Rich-Harris be46c94
prevent conflicts
Rich-Harris f8e6696
update docs
Rich-Harris b880f74
regenerate
Rich-Harris a7aa1a7
fix link
Rich-Harris bd0157a
add Attachment interface
Rich-Harris c69c5d7
beef up test
Rich-Harris 999a05a
regenerate
Rich-Harris 339ce84
tweak types
Rich-Harris 8255bc6
fix
Rich-Harris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': minor | ||
--- | ||
|
||
feat: attachments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/svelte/src/compiler/phases/3-transform/client/visitors/AttachTag.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** @import { Expression } from 'estree' */ | ||
/** @import { AST } from '#compiler' */ | ||
/** @import { ComponentContext } from '../types' */ | ||
import * as b from '../../../../utils/builders.js'; | ||
|
||
/** | ||
* @param {AST.AttachTag} node | ||
* @param {ComponentContext} context | ||
*/ | ||
export function AttachTag(node, context) { | ||
context.state.init.push( | ||
b.stmt( | ||
b.call( | ||
'$.attach', | ||
context.state.node, | ||
b.thunk(/** @type {Expression} */ (context.visit(node.expression))) | ||
) | ||
) | ||
); | ||
context.next(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/svelte/src/internal/client/dom/elements/attachments.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { effect } from '../../reactivity/effects.js'; | ||
|
||
/** | ||
* @param {Element} node | ||
* @param {() => (node: Element) => void} get_fn | ||
*/ | ||
export function attach(node, get_fn) { | ||
effect(() => { | ||
return get_fn()(node); | ||
Rich-Harris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/svelte/tests/parser-modern/samples/attachments/input.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div {@attach (node) => {}} {@attach (node) => {}}></div> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.