Closed nrn closed 8 years ago
That could be done by using morphdom
or diffhtml
directly:
var bel = require('bel')
var element = bel`<div>hello</div>`
// ... later ...
var morphdom = require('morphdom')
var newelement = bel`<div>changed</div>`
morphdom(element, newelement)
But I have it tied to the element to encourage data down, actions up. I'd be worried about elements getting updated by multiple sources and conflicting with each other.
It is surprising to me for real dom elements to have extra methods on them, but it totally makes sense why you're going that way!
I considered replacing .outerHTML
with a setter to the update function but wasn't sure if that was a good idea or not. See #6
Maybe better wording would be, "almost pure elements." :)
Any thoughts on trasitioning update to being a function that takes the old element as it's first argument, instead of adding a property to the element? It feels like it would fit better with my expectations approaching the interface. And it seems like you could then update elements not created by bel, which would be nice.