How do I get around SPA framework undoing inserted CSS style?

I have a site and it uses Svelte. I inject custom CSS styling to certain rows of the table, but the styles seems get swapped into totally different rows as soon as the Table get updated with new data.

I tried to debug this issue using Devtools. From what I observe, Svelte reuse tds and change their text contents

The CSS style is injected using Javascript like this,

const tds = tr.getElementsByTagName("td");

tds[1].style.background = "black"