| <!DOCTYPE html> |
| <html> |
| <head> |
| <script type="text/javascript" src="RangeTest.js"></script> |
| <script> |
| |
| function createElementWithId(elementName,id) |
| { |
| var element = DOM_createElement(document,elementName); |
| DOM_setAttribute(element,"id",id); |
| return element; |
| } |
| |
| function performTest() |
| { |
| // DOM_wrapNode() should not affect any positions, because the node itself remains in the |
| // tree unmodified. |
| |
| DOM_deleteAllChildren(document.body); |
| |
| var p = DOM_createElement(document,"P"); |
| |
| var span1 = createElementWithId("SPAN","span1"); |
| var span2 = createElementWithId("SPAN","span2"); |
| var span3 = createElementWithId("SPAN","span3"); |
| var span4 = createElementWithId("SPAN","span4"); |
| var span5 = createElementWithId("SPAN","span5"); |
| DOM_setAttribute(span1,"style","color: blue"); |
| DOM_setAttribute(span5,"style","color: blue"); |
| |
| DOM_appendChild(document.body,p); |
| DOM_appendChild(p,span1); |
| DOM_appendChild(p,span2); |
| DOM_appendChild(p,span3); |
| DOM_appendChild(p,span4); |
| DOM_appendChild(p,span5); |
| |
| DOM_appendChild(span2,createElementWithId("BR","br1")); |
| DOM_appendChild(span2,createElementWithId("BR","br2")); |
| DOM_appendChild(span2,createElementWithId("BR","br3")); |
| DOM_appendChild(span3,createElementWithId("BR","br4")); |
| DOM_appendChild(span3,createElementWithId("BR","br5")); |
| DOM_appendChild(span3,createElementWithId("BR","br6")); |
| DOM_appendChild(span4,createElementWithId("BR","br7")); |
| DOM_appendChild(span4,createElementWithId("BR","br8")); |
| DOM_appendChild(span4,createElementWithId("BR","br9")); |
| |
| var result = comparePositionsBeforeAndAfter(function() { |
| |
| // Temporarily remove id attributes so that elements will be considered mergeable |
| DOM_removeAttribute(span1,"id"); |
| DOM_removeAttribute(span2,"id"); |
| DOM_removeAttribute(span3,"id"); |
| DOM_removeAttribute(span4,"id"); |
| DOM_removeAttribute(span5,"id"); |
| |
| Formatting_mergeWithNeighbours(span3,Formatting_MERGEABLE_INLINE); |
| |
| DOM_setAttribute(span1,"id","span1"); |
| DOM_setAttribute(span2,"id","span2"); |
| DOM_setAttribute(span3,"id","span3"); |
| DOM_setAttribute(span4,"id","span4"); |
| DOM_setAttribute(span5,"id","span5"); |
| |
| }); |
| |
| |
| DOM_deleteAllChildren(document.body); |
| DOM_appendChild(document.body,DOM_createTextNode(document,"-\n"+result+"\n-")); |
| } |
| </script> |
| </head> |
| <body> |
| </body> |
| </html> |