How to prevent node update
JSteunou opened this issue · 7 comments
Hi, great work over there, I very like what you are doing!
I just had one question: say I have a view's template with one element handled by another library than diffhtml and I dont want it to be patched / updated. What would be the best way to prevent that?
I think the best way to do this would be with middleware. I'll try and come up with something!
If this can help you, I know than nanomorph uses isSameNode
el property
I did something like this in the framework I'm building on top of diffhtml. Here's how I did it.
Yup, that's pretty much how I'd recommend doing it as well. Pretend the new node is the same as the old node. That way you don't even need to worry about isSameNode
or needless additional syncing.
Here is a reduced solution (based off @mAAdhaTTah's code): https://glitch.com/edit/#!/diffhtml-prevent-node-update?path=prevent-update.js:9:21
I'm basing this off the class
attribute, but you could theoretically use any attribute to figure out what to block.
This is definitely doable with the current implementation. Minor bug (#153) may not impact your actual use case but will be resolved in the next release. Let us know if you have other issues.
Nice solutions guys ! The middleware system is great.