Comments (3)
For what it's worth, React has the same issue when re-using nodes within a component but not when using separate components. Does Elm have the equivalent of that second React example?
from virtual-dom.
This is one of the cases where it is recommended to use a Html.Keyed.node
.
Here is your example fixed with this technique.
from virtual-dom.
I think we're having the same conversation on Reddit. I'm aware that keying the nodes will force a re-render and fix the problem in my specific and contrived example. I don't think it's reasonable to expect Elm developers to a) know that this issue exists and b) know how to use Html.Keyed
properly (using it too much affects render performance, using it too little leaks state between unrelated nodes).
What I was hinting at in my previous comment is that other virtual DOM implementations have implicit keying (or enforce explicit keying in certain circumstances) in a way that makes this a non-issue. I think it's reasonable for Elm to attempt to do the same. One way might be for Elm to implicitly key child views based on their function name.
from virtual-dom.
Related Issues (20)
- VirtualDom.lazy fires when arguments are constants
- Styles get lost after model update HOT 1
- `javascript:` ban disallows legitimate use for bookmarklets HOT 4
- Html.map with IE11: Unable to get property 'j' of undefined or null reference HOT 3
- Possible to bypass XSS filter with nodeNS HOT 3
- Reusing anchor node leaves empty href attr HOT 1
- Html.map + timeupdate event after DOM removal creates invalid Msg
- Uncaught TypeError: Cannot assign to read only property 'className' of object [DOM mutations from FontAwesome] HOT 1
- textarea [type_ "text"] [] blows up Elm HOT 1
- Lack of good error message when HTML document is malformed
- node removal in `_VirtualDom_diffKeyedKids` when prepending items HOT 3
- `</script>` in string literals is not escaped for embedding elm.js directly in HTML
- Redundant removal and reinsertion of node breaks focus on element HOT 6
- Preventable runtime error caused by setAttribute '' HOT 2
- Adding type_ attribute to textarea throws error in runtime
- Html.Keyed.node does not preserve scroll positions across children
- lazy can cause loss of user's input focus HOT 1
- Child elements not added to <template> elements
- Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from virtual-dom.