Hi all!

I've been working on a board game using elm and I'm using svg for 
rendering. I render the game by first drawing the board in the background, 
and then I render one square for each tile that can hold a game piece. When 
implementing this, I created a svg symbol for every variation of the tiles 
(empty, filled, mouse over,...) and for each tile rendered, I reference the 
symbol to use with the *use* tag and *xlink:href* attribute.

To start with, for unknown reason, chrome fires an event every time the 
mouse moves over a tile even if I only register for mouseover events on the 
tiles. This would be fine if it wasn't for the fact that the whole board is 
being re-rendered on *every* mouseover event, even though the underlying 
model never changes (mouse is only moving inside a tile, so ideally I 
wouldn't have to redraw anything).

When digging into the javascript code, I noticed that the diff mechanism 
always marks the whole model as being changed, and therefor force a full 
re-render. However, when I manually diff json representations of the model, 
I see that they are identical. I noticed that when *diffFacts* is being 
called with the use tags' attributes object (containing the *xlink:href*), 
it always marks it as a change even if they are identical.

For comparison, I made an isolated version where I compared rendering two 
tiles using symbols vs just simply rendering rect tags directly (switching 
the fill color). And as expected, for the non-symbol version, re-render is 
only triggered when the model actually changes, and always triggered when 
using symbols.

Here is a gist for the isolated 
version https://gist.github.com/Shump/bd778bde23af0dd3f8c95f92ec45fc33

Any idea if this is expected behavior? Or is this a bug with the virtual 
dom code?

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to