-
Notifications
You must be signed in to change notification settings - Fork 26
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
Maybe do not evaluate elements. #54
Comments
Hi @uvelichitel -- The IIFE that the compiler generates was largely just to give us our own lexical namespace, so that we don't pollute surrounding code with our symbols. It's an interesting idea, that a JSX expression would produce functions instead of nodes. The two concerns that immediately jump to mind are:
-- Adam |
OK than |
+1
Is this really a major problem in pre-1.0.0 stage?
I was thinking that in JSX should produce code that produces my-html-element when needed, upon demand. I do really like the idea that Surplus eliminates the need for VDOM nodes and generates code that produces real DOM nodes. I would love to see a more flexible approach where Surplus generates code that produces the real DOM nodes upon demand, when needed. P.S. Another consequence of the idea discussed here is that it would not be possible to change attributes like |
If something that 'produces a node on demand' is needed, isn't it basically the same as this?
To me, that's one of the clearer ways you can express this idea. True, if a function is generated, then some features like caching or whatnot for performance can be added, but that seems a completely different territory as well. |
Plus, seeing as how Surplus is still one of the fastest JSX frameworks according to benchmarks, I think V-Doms are less of an issue. |
First, thanks for sharing. I'm very appreciate and use your code in own projects.
Now, JSX compiler emits nodes with perfectly readable code
I can mount view
document.body.appendChild(view)
only once because of DOM rulesMaybe will be meaningful to leave view() been a function but not evaluate it. This allow instantiate
document.body.appendChild(view())
any times needed. Also it allows to easily write functional componentsconst Component = ((props) => <div>{props.content}<div>)
and use em like a template
If you agree this can make sense, than I can pull request, or you can do it yourself - just remove
)()
call in compiler's codegen(). I done it and test in my local repo and things work as expected.The text was updated successfully, but these errors were encountered: