-
Notifications
You must be signed in to change notification settings - Fork 781
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
Change internal VNode data structure. #578
Comments
No objections here. As you say, this is an internal change, so it doesn't really affect users unless they were creating their own raw VNodes. I'm not seeing how you could intermingle Or is the idea that stateless functional components from preact could be used directly in a hyperapp view? Such as a purely stylistic UI library. |
@SkaterDad your final statement..
and vice versa.. It would be nice if the views (stateless at least) were not tied to a specific vdom implementation. Further food for thought is trying to rally together all vnode implementations and establishing an industry/community standard. Not sure exactly how sensible/realistic that is but it seems logical! |
Not sure if you need to make this kind of a change for stateless functional components. They are already mostly transparent across React, Inferno, Preact and even Picodom because its the h function that does the transformation for the particular library. I have moved stateless functional components between all four and more without a problem, so changing an internal name used by Hyperapp's h function won't affect this type of reuse of functional components. Nobody creates a VNode from scratch, they use a hyperscript-compatible function to do that. The only gotcha in reusing functional components is the React-specific attribute convention: |
@SkaterDad Take |
Why not target Inferno VNodes, considering that Inferno is one of the most performant frameworks according to https://github.com/krausest/js-framework-benchmark? |
Inferno, like React, uses the term |
@brodybits Performance is not the most important metric when choosing a framework. It's not even close to the top in my book. But if Inferno and React use the same VNode, then Inferno+React > Preact IMO. |
@rbiggs You mean a runtime check no? If so, no, that would kind of defeat this initiative. |
In case anyone needs backward thing (to generate compatible vNode structure with hyperscript) import import { h as _h } from 'hyperapp';
export const h = (...args) => {
const { name, props, children } = _h(...args);
return { name, props, children, nodeName: name, attributes: props }
} |
Yeah, I looked at the source code. Not gonna work. One thing, Hyperx just takes the library's h function to return a factory. But I don't see any easy way to do that for all of the tags. |
Removing breaking, because this is not technically a breaking change if we consider breaking changes only changes that break the external / public API, which this is not. |
I'd like to discuss the possibility to change our internal VNode data structure
name
andprops
fields tonodeName
andattributes
respectively.This is an internal breaking change, so I don't believe it warrants a major bump. If you know semver better than I do, can you please help me confirm this?
Before
After
Why?
It makes Hyperapp VNode object compatible with Preact and possibly other libraries that use the same schema. I think React uses
elementName
instead, which is a shame.This is useful if you are authoring a tool that outputs virtual nodes (e.g., @lukejacksonn's ijk or a JSX plugin that transforms JSX to VNodes skipping hyperscript syntax).
Maybe you want the library to be compatible with Hyperapp out of the box without having to distribute a Hyperapp-specific build or use a constructor function to register the VNode schema, but you also want to support at least another framework such as Preact.
Related
The text was updated successfully, but these errors were encountered: