I'm trying to avoid CSS Reflows,
usually DocumentFragment is enough for my needs.
I have cases when I modify/add/remove datasets,
The problem is that each dataset require one operation which causes reflow..
element.dataset is a read only object, so I wondered how can I do it with only one reflow instead of 3 in this example?
element.dataset.a='1'
delete element.b
element.dataset.c='2'
Does replacing the element completely is the only way to achieve this?
Changing the dataset of an element will not cause a synchronous reflow. You can do it as many times as you'd like during the same task.
To test if something causes a reflow or not, you can use a CSS transition.
Going from a known state, then setting an intermediary state, triggering what should cause the reflow and finally setting back the original state.
If the tested action did trigger a reflow, then a new transition from the intermediary state to the final one will happen. If no reflow did happen, then no transition will happen.