Keep mutated DOM on scroll



I wanted to add a little rainbow-parens plugin. I didn’t know Atom unloads non visible DOM elements on scroll and went directly with manipulating the Node tree:

The result, as soon as the user scrolls, the colors (and my custom classes) are gone.

What are some APIs I could use for this? Can I somehow persist my mutated classes?


You would probably have to use the Decorations API.


thanks for the tip! I played a bit around with that API but wasn’t able to actually color the brackets.

With the highlight option, this was what I came up with:
But having a colored block around each bracket is very distracting.

With the line option, there is no way to separate brackets on the same line. All brackets would have the same color.

Am I missing something here?


No, you’re not missing anything. This is what Atom currently has available to do what you were asking for.


That is slightly disappointing. Back to my original question then, is there any way to persist dom changes so when atom loads it back in, it still has the changed attributes (just a class in my case)?


I also tried to implement such plugin but using grammar injection. But there is a problem described in this issue which prevents name overriding.


No. The only lines in the DOM are the ones visible. They are created and deleted constantly.