-
Notifications
You must be signed in to change notification settings - Fork 32
core: Custom element objects #245
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
bterlson
merged 7 commits into
alloy-framework:main
from
witemple-msft:witemple-msft/custom-element
Sep 5, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
25f2250
Add a custom element child type
willmtemple d747cf5
chronus
willmtemple c8b3551
Merge remote-tracking branch 'upstream/main' into witemple-msft/custo…
willmtemple cc15a53
Workshop the naming a little bit
willmtemple 67b617d
Some docs and comments
willmtemple bfa68e6
Merge remote-tracking branch 'upstream/main' into witemple-msft/custo…
willmtemple f0424f5
Merge branch 'main' into witemple-msft/custom-element
bterlson 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
7 changes: 7 additions & 0 deletions
7
.chronus/changes/witemple-msft-custom-element-2025-6-22-19-3-51.md
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,7 @@ | ||
| --- | ||
| changeKind: feature | ||
| packages: | ||
| - "@alloy-js/core" | ||
| --- | ||
|
|
||
| Adds a new type of Alloy child, CustomChildElement, that is based on the presence of a symbol property. |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats the use case for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use case is to be able to create objects that act as children in the tree. These can be class instances that carry additional metadata, for example, but have some essence of component-ness within them.
I have a thing I've been using called an "ExpressionBuilder" that allows me to compose syntax using a fluent-style API that is highly type-driven. Think like,
StringShape.literal("asdf").encodeBuffer("utf-8")composes an expression that takes the literal string "asdf" and encodes it into a Buffer object, but it doesn't actually do that computation, it builds syntax that will do that in the output tree. But when I want to insert the built expression into the alloy tree, I have to destructure it first in a kind of complicated way, because it has a "preamble" part and then an expression part. What I want to do is be able to make the ExpressionBuilder itself usable as if it were an Alloy component, so for example if I want to call an expression I've built up, I can just say<ts.FunctionCall target={expressionBuilderInstance} />without having to wrap it in a special "destructure ExpressionBuilder" component. This thing is really designed such that it should be usable as an expression and having a little protocol like this in Alloy to be able to just implement the behavior of rendering an ExpressionBuilder directly is a little bit more convenient than having to wrap everywhere I want to insert one of these things into the tree.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that in a way a more generic version of this #237
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the JSON object child in that PR could be implemented in terms of this, yes. You would just implement this custom child interface to render the JSON object instead of having a special symbol that tells the renderer to use a specific implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like this idea in general because I don't really like the way we have of treating json as text to render it. But I don't fully get form the one test how this is to be used.
If that's not too much work could you add more test/show how the json test I wrote in that other pr would work