Runs in a real DOM. Each test seeds
<div id="content">with a small fragment of HTML.
Implement highlight(term) that wraps every case-insensitive occurrence of term inside text nodes of #content in a <mark> element, preserving the original casing of the matched text, and returns #content's innerHTML.
Rules that make this the interview question it is:
- Only text is searched. A match inside an attribute (
title="cat") or a tag name must not be touched. - Existing elements stay where they are:
Hello <b>world</b> hellokeeps its<b>. termis literal text, not a regex:"a.b"must matcha.band notaxb.- An empty or whitespace-only
termchanges nothing.