chromakode / diablo

yo-yo.js, with added components
15 stars 0 forks source link

Div container #1

Open alvarezgarcia opened 7 years ago

alvarezgarcia commented 7 years ago

Hi, I am newbie in this modules (bel, yo yo, etc) and I al reading source just to understand it.

I was doing some tests with yo yo and I saw that if I put a div under a list of elements it gets re render (even if the div was exactly the same, using getElementById), but if put it above the list it was ok.

Just for trying I wrap the div that was under the list with another div (like you do with the container) and it worked ok (I mean don't get re render).

I know that I am talking about yo yo, but reading your source code about the wrapping with the div.. I was curious why you do that.

Many thanks for this module and your work and sorry for my bad english.

chromakode commented 7 years ago

Hi @raichuk! It might be easier to figure out what is going on if you created a jsfiddle/jsbin/codepen demonstrating the behavior you're seeing.

The reason I wrap with a div in the render function is that I want to diff the contents of the container element with my new results. I wrap with an extra div so that the new rendered elements are at the same depth as the container's children. Then if you use morphdom with childrenOnly=true it will update the rendered contents of the container but not the container element itself. I think this is actually a bug in my code, because it currently passes childrenOnly=false.

Hope this helps! I've found the easiest way to figure out what morphdom is doing is run it manually and step through in a debugger. It's pretty simple code and following its internal logic will help you understand how to use it efficiently.