¿Cómo puedo resaltar el texto del objeto DOM Range?

Selecciono un texto en la página html (abierto en Firefox) usando el mouse, y usando las funciones de JavaScript, creo / obtengo el objeto range que corresponde al texto seleccionado.

 userSelection =window.getSelection(); 
 var rangeObject = getRangeObject(userSelection);

Ahora quiero resaltar todo el texto que viene debajo del objeto range. Lo estoy haciendo así,

  var span = document.createElement("span");
  rangeObject.surroundContents(span);
  span.style.backgroundColor = "yellow";

Bueno, esto funciona bien, solo cuando el objeto range (punto de inicio y punto final) se encuentra en el mismo nodo de texto, luego resalta el texto correspondiente.

    <p>In this case,the text selected will be highlighted properly,
       because the selected text lies under a single textnode</p>

Pero si el objeto range cubre más de un nodo de texto, entonces no funciona correctamente, resalta solo los textos que se encuentran en el primer nodo de texto, Ex

 <p><h3>In this case</h3>, only the text inside the header(h3) 
  will be highlighted, not any text outside the header</p> 

¿Alguna idea de cómo puedo hacer, todos los textos que vienen bajo rangeobject, resaltados, independientemente de si el rango se encuentra en un solo nodo o en un nodo múltiple? Gracias....

Respuestas a la pregunta(4)

Su respuesta a la pregunta