You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wraps a DOM Range instance with the specified DOM node name
Installation
$ npm install wrap-range
Example
varwrapRange=require('wrap-range');// create a DIV with some contentvardiv=document.createElement('div');div.innerHTML='hello world';// append it to the pagedocument.body.appendChild(div);// create a Range instance pointing to some of the textvarrange=document.createRange();range.setStart(div.firstChild,1);range.setEnd(div.firstChild,8);// now we can "wrap" the Range with an element node type,// say U to underline in this case:varuNodes=wrap(range,'u');assert.equal(uNodes.length,1);assert.equal(uNodes[0].nodeName,'U');assert.equal(uNodes[0].innerHTML,'ello wo');assert.equal(div.innerHTML,'h<u>ello wo</u>rld');