-
-
Notifications
You must be signed in to change notification settings - Fork 113
Node reordering issues #115
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
Comments
Just a small update. Everything renders as expected if the original array is cloned on each update. See this fiddle. However the original example in the documentation suggests that in-place array mutations should be possible too, so I still think this is an issue. |
hey @yuretz nice bug report. It looks like this bug may have been introduced with #100. Testing your original example against |
nice bug indeed ... but majinbuu is just fine. There is something weird going on here, the logic is perfectly fine but it misses one call. I will investigate more tomorrow but so far this works, which is reassuring: const todo = [
{id: 0, text: 'write documentation'},
{id: 1, text: 'publish online'}
];
const list = [];
const aura = majinbuu.aura({splice() {
console.log(arguments);
return list.splice.apply(list, arguments);
}}, list);
majinbuu(aura, todo);
todo.push({id: 2, text: 'create Code Pen'});
majinbuu(aura, todo);
const strcmp = (a, b) => (a > b ? 1 : (a < b ? -1 : 0));
todo.sort((a, b) => strcmp(a.text, b.text));
majinbuu(aura, todo); For some reason, the sort splice is invoked once instead of twice ... and not sure why is that. |
P.S. and FYI: the reason cloning each object works is that you are creating new wires each time (always different nodes) |
Oh and also:
for the record |
that's just an attribute, but here I have bigger problems to deal with ... 🤷♂️ |
@yuretz can you please test this version and tell me if everything looks good to you? Thanks edit this is the fiddle with this version https://jsfiddle.net/58cnrsq4/ |
@joshgillies I don't know React much so I don't know what's wrong there. Does react deal in a special way with |
@WebReflection confirmed with @yuretz original example that the latest as of 2495c8d resolves the issue. Also regarding |
I've also added the sorting test case and it's covered now. Since the fix is super ugly but kinda obvious, I'm going to push this as patch regardless (or I cannot sleep tonight) |
@WebReflection adding a test case would be 👌 Nice work! |
|
Wow! That was fast super fast. Thank you for the fix and explanations! @joshgillies I confirm, that I was indeed confused by |
There is no virtual DOM in hyperHTML and the diffing is powered by Levenshtein distance through Majin Buu splice-based engine, which is there to perform the least amount of DOM operations to change from list-1 to list-2 in place. Attributes in hyperHTML address actual DOM attributes, and nothing else. These are never special, unless these are events, a In hyperHTML the DOM is always optimized, which is also why you don't need, as developer, to hint optimizations, hyperHTML does that for you out of the box. One question though: is Thanks. |
There's a special attribute called |
I am using ... what? I'm just setting a |
@asapach said that the use of This is exactly the case. Yuretz was confused and thought that the That said, I believe that @joshgillies was also confused about the |
everyone is confused, including me 😄 I feel like I cannot use attributes in hyperHTML examples or someone will be confused ... React page explicitly describes Should I name it |
I'd just remove it to avoid confusion. |
done |
Thank you guys and sorry for confusion I managed to create 😳 |
LOL This thread it 💯 ! To be clear @papas-source I never said |
ohh Riot! I wish there was a library that its syntax was close to Riot's syntax (which is - in my opinion - by far the best component-like friendly syntax) and its internals based on HyperHTML to be fast! |
AFAIK that's already happening ... they were thinking of using hyperHTML |
First of all I would like to thank you for your awesome work. This micro-framework/library looks really interesting and very promising indeed.
I was playing with the example provided here and stumbled upon a couple of issues.
The first one is that sometimes, when re-rendering a re-ordered array, the first item is not displayed. I've tried both with
data-id
attribute in the template and without it, it doesn't help much. What am I doing wrong here?The second one is just a
DOMException
being thrown when trying to render the reordered array.Both issues are illustrated by this fiddle
The text was updated successfully, but these errors were encountered: