I recently came across a layout thrashing issue and wanted to confirm if my understanding is correct.
What I was doing
Let element = document.getElememtById(id);
Let element2 = document.getElementById(id2);
element.style.margin = element2.style.margin
This code was causing the layout thrashing as I was getting the margin value of element2 in my js code (which requires layout calculation) and then setting another element's margin value which makes previous layout invalid.
I am not calculating the margin value for element2 now and storing it in some variable, the code now looks like
Let element2 = document.getElementById(id2);
element.style.margin = variable
Does setting the margin here lead to layout thrashing or is that acceptable?