Replies: 2 comments 2 replies
-
|
Sorry for the late reply! The reason I had to remove caching was that hyperapp internally mutates the virtual-nodes during it's patching process, and uses those mutations to keep track of ... something in the patching process. I don't know. I just realized that if I passed the same (cached) virtual-node to hyperapp multiple renders in a row, there would occasionally be strange rendering bugs. So I just decided to take out the caching all together. It's all pretty snappy anyway. You can use hyperapp's built-in |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for the answer. I didn't realize the cache was done based on v-nodes. When I was thinking about it I was thinking of transformation of the string literal to another data structure, cache this one, and apply literal values to it to generate the v-nodes using const todos = ({items}) => jsx`TODOs: <ul foo="bar">${items.map(item => jsx`<li>${item}</li>`)}</ul>`to something like this item = ['li', {}, [0]] // zero means first parameter from literal values
todos = ['TODOs', ['ul', {foo:'bar'}, [0]]]Benefit would be the string parsing is done only once. All the SVX logic including structure validation. Based on your comment I have tried to make changes to your code to add this idea to it, but realized your implementation is "happy path based"; no validation at all 😄 The topic was interesting to me enough to give it a try to see how the whole solution would look like. So in a meantime I have implemented the whole stuff. I did my own parsing (heavily inspired by yours) to include validation and then added the caching too. In case you would be interested I placed it here https://github.com/hrachovm/ha-jsxlit/blob/master/jsxlit.js |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a nice little package, but I am curious why the caching was removed.
I found this change in history b9be5b3
Can I ask what was the reason for it?
Beta Was this translation helpful? Give feedback.
All reactions