In JavaScript, I would like to split a node to separate text and children. Consider the following node:
<p>text <b>bold</b> and <i>italic</i></p>
I would like to get an array (or something iterable) that looks like:
"text" => text
<b>bold</b> => child
"and" => text
<i>italic</i> => child
How to do this in an efficient and elegant way?