-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
feat(runtime-vapor): component props #40
Conversation
Size ReportBundles
Usages
|
}, | ||
|
||
render(_ctx) { | ||
const t0 = template('<button></button>') |
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.
In this design, what I understand is that the DOM finally generated by the template is like this
<button></button><Comp></Comp>
-> <button></button><p>3 * 2 = 6</p>
This is a fragment, but how to deal with a structure like this? I don't seem to see similar logic in the code
<button><Comp></Comp></button>
-> <button><p>3 * 2 = 6</p></button>
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.
Since renderComponent
can take a container as its third argument, I think it can be achieved by passing the button's Node as the container. 🤔
const t0 = template('<button></button>')
const n0 = t0()
const {
0: [n1]
} = children(n0)
on(n1, 'click', _ctx.handleClick)
renderComponent(
child,
{
get count() {
return _ctx.count
},
get inlineDouble() {
return _ctx.count * 2
}
},
n1 // button node
)
2023-12-12.14.38.16.mov
I've written TODO comments in the import statements, and I've mentioned this in the description of this PR as well, but since I'm using the existing render function somewhat forcibly, I'm thinking of implementing a function like createComponent
.
Closes #25
Summary
I have implemented several functions referring to runtime-core/src/componentProps.ts.
In order to add propsOption, I have tried changing it to an object like the following:
I have also implemented
ComponentPublicInstance
to combine setupState and Props as ctx.Concerns (Points I'm not sure about)
Since solid seemed to implement it using getters, I'm referring to that for now. (There may be room for discussion)
This time, it was only about implementing props, so if necessary, it would be better to work on it in a separate issue.
How to confirm the operation
Since the compiler implementation is not yet available, I have written the expected JavaScript code as the compilation result in
playground/src/props.js
.code
2023-12-08.0.21.33.mov