-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Proposal] Snabbdom V2 #359
Comments
I suggest introduce similar DOM APIs for modules too. For example, |
Good ideas, I support this. |
@katyo I'm not proposing any changes on the modules, We should also discuss how to approach the process of introducing v2, and the branch strategy in case we need/want to patch v1 in the future. |
I'd actually recommend making a new package, either |
Definitely lots of good ideas 👍 Related to the point about better test infrastructure I'd like to mention that having CI would be really nice.
As in a new npm package? That sounds like something that would be a source of confusing to me. If necessary we could have a branch for the old version and also release patches to that version on npm. |
@paldepind We plan to push the v2 with CI and perf runner included :) |
@caridy can I propose an improvement for the eventListener module? Listening events on body by default and maintain an internal map of listeners in order to do global event delegation like React does. |
@JSteunou yes, but I will recommend to be caution because that doesn't work with shadow DOM and some custom events, and probably mislead users. The alternative is always to have a new npm package that provides a replacement/alternative of the module provided by this project, and we can probably start listing 3rd party modules in the README. |
@katyo , good day. I've thought the same and even liked this with 👍 . But I have a new thought now: all Snabbdom is strongly DOM-oriented and DOM-specific. See: whole attributes module should be "interfaced" in this case. Even Now I have a new thought: even remove |
On children normalization, see also: #362 (comment) |
Snabbdom V2
This issue is a placeholder for some discussions about snabbdom v2.
Goals
Other changes
Details
1. Perf Improvements
2. Size Reduction
3. Custom Comparison
Using
key
andsel
as a way to determine whether or not two vnodes are alike can still cover a lot of ground, but in some cases, users might want to apply a more restrictive mechanism to avoid recycling old vnodes. We should provide a way to define such comparison as an extension point.4. Children collection could be normalized by modules
As today, the children reference is stored before invoking
update
orcreate
hook, this makes it difficult for modules to do any kind of slotting or normalization of children without mutating the originalchildren
array, which is not ideal and goes against the principle of snabbdom of never mutating objects that it doesn't own.A possible solution is to only extract the
children
value of the vnode after all modules are done with theupdate
orcreate
process.5. Core vs Helpers vs Modules
This project contains the "core lib" whos job is to diff and patch, it also contains a default set of modules that covers most common cases for a DOM Element patching, and a set of helpers to pave the way for users to adopt snabbdom for the Web. This separation is not clear today, and should be very explicit in the next version. The proposed separation is:
attachto
,h
,thunk
,tovnode
snabbdom
plus the types defined inhooks
andvnode
Additionally, I believe
htmldomapi
should be a helper too, and should be a required argument of the init method to keep the separation clear, while snabbdom can focused on the critical path only.6. Formalizing workflow
As today, there are some arbitrary conditions to call certain hooks for certain types of vnodes, or certain type of data, these conditions seems arbitrary to the best of my knowledge, and I will like to formalize them. E.g.: vnodes with only a text will never go thru the create/destroy hooks. In some other cases, vnodes without data are not good for create/update.
The text was updated successfully, but these errors were encountered: