-
Mark Florian authored
Before, any elements that were siblings of matching text nodes got destroyed, replaced with their normalised `textContent`. That is, given this DOM: ```html <p> Foo <i>bar</i> qux. </p> ``` If you searched for `foo`, then the above would be transformed into something like: ```html <p> <mark>Foo</mark> bar qux. </p> <!-- But the correct DOM would be: --> <p> <mark>Foo</mark> <i>bar</i> qux. </p> ``` And then if you cleared the search, it would become: ```html <p> Foo bar qux. </p> <!-- But the correct DOM would be the same as before the search: --> <p> Foo <i>bar</i> qux. </p> ``` The crux of the problem was that the *highlighting* algorithm wasn't the inverse of the *highlight clearing* algorithm. Now, it is, and only text nodes are modified. Matching text nodes are split into non-matching text nodes and `mark` elements containing the matched search text, and that collection of nodes replaces the original text node. Addresses https://gitlab.com/gitlab-org/gitlab/-/issues/350494. Changelog: fixed
6900d26c