Closed NullVoxPopuli closed 3 years ago
code.innerText = sample;
This line is broken. innerText does NOT properly preserve line breaks. Try innerHTML or textContent or one of those other APIs.
but then why do line breaks exists without the highlight being applied?
though, I do confirm that using textContent resolves my problem. I'd still like to know why innerText behaves different and what specifically is different
You also should be able to just test that setting innerText and then immediately retrieving textContent - the line breaks have already been destroyed... if you ask for innerText
from an existing node it will not include proper line breaks. It's annoying, i don't remember all the details but Google is your friend if you really must know.
Closing as behaving as expecting.
Describe the issue/behavior that seems buggy
Given this HTML:
I see this output:
But, if I comment out the highlighting line:
there are, indeed retained.
In v10, the line breaks were retained