rem: } 
add: else {  while (anchorParent.localName in NotAnInlineParent) { anchor = focus = anchorParent; anchorSelected = focusSelected = true; anchorParent = anchor.parentNode; ordered = true; } } 
context: function InsertElementAroundSelection(element){  // We need to find a suitable container for the element.  // First get the selection  var anchorParent = editorShell.editorSelection.anchorNode;  if (!anchorParent.localName)    var anchorSelected = true;  else if (editorShell.editorSelection.anchorOffset < anchorParent.childNodes.length)    var anchor = anchorParent.childNodes[editorShell.editorSelection.anchorOffset];  var focusParent = editorShell.editorSelection.focusNode;  if (!focusParent.localName)    var focusSelected = true;  else if (editorShell.editorSelection.focusOffset < focusParent.childNodes.length)    var focus = focusParent.childNodes[editorShell.editorSelection.focusOffset];  // Find the common ancestor  var anchorDepth = nodeDepth(anchorParent);  var focusDepth = nodeDepth(focusParent);  if (anchorDepth > focusDepth)  {    anchor = nthParent(anchorParent, anchorDepth - focusDepth - 1);    anchorParent = anchor.parentNode;    anchorSelected = true;  }  else if (anchorDepth < focusDepth)  {    focus = nthParent(focusParent, focusDepth - anchorDepth - 1);    focusParent = focus.parentNode;    focusSelected = true;  }  var ordered = false;  while (anchorParent != focusParent)  {    anchor = anchorParent;    anchorParent = anchor.parentNode;    focus = focusParent;    focusParent = focus.parentNode;    anchorSelected = focusSelected = true;  }  // The common ancestor may not be suitable, so find a suitable one.  if (editorShell.NodeIsBlock(element))  {    // Block element parent must be a valid block    while (!(anchorParent.localName in IsBlockParent))    {      anchor = focus = anchorParent;      anchorSelected = focusSelected = true;      anchorParent = anchor.parentNode;      ordered = true;    }  }  else  {    // Inline element parent must not be an invalid block    while (anchorParent.localName in NotAnInlineParent)    {      anchor = focus = anchorParent;      anchorSelected = focusSelected = true;      anchorParent = anchor.parentNode;      ordered = true;    }  }  // We now have an ancestor to hold the element  // and a range of child nodes to move into the element  if (anchor != focus)  {    if (!ordered)    {      // Ensure anchor <= focus      for (var node = anchorParent.firstChild; node != anchor; node = node.nextSibling)      {        if (node == focus)        {          focus = anchor;          anchor = node;          focusSelected = anchorSelected;          break;        }      }    }    if (focus && !focusSelected)      focus = focus.previousSibling;  }  if (!editorShell.NodeIsBlock(element))  {    // Fail if we're not inserting a block    if (!anchor) return false;    for (node = anchor; ; node = node.nextSibling)      if (!node)        return false;      else if (nodeIsBlock(node))        break;      else if (node == focus)        return false;  }  // The range may be contained by body text, which should all be selected.  if (!nodeIsBlock(anchor))    while (!nodeIsBlock(anchor.previousSibling))      anchor = anchor.previousSibling;  if (!nodeIsBlock(focus))    while (!nodeIsBlock(focus.nextSibling))      focus = focus.nextSibling;  editorShell.BeginBatchChanges();  try {    var anchorOffset = 0;    // Calculate the insertion point for the undoable InsertElement method    if (!anchor)      anchor = anchorParent.firstChild;    else      for (node = anchorParent.firstChild; node != anchor; node = node.nextSibling)        anchorOffset++;    editorShell.InsertElement(element, anchorParent, anchorOffset, true);    // Move all the old child nodes to the element    // Use editor methods in case of text nodes    var editor = editorShell.editor;    while (anchor)    {      node = anchor.nextSibling;      editor.deleteNode(anchor);      editor.insertNode(anchor, element, element.childNodes.length);      if (anchor == focus) break;      anchor = node;    }  }  catch (ex) {}  editorShell.EndBatchChanges();  return true;}
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/a0885fe3052b87d392163c81f32552d543df0f50/EdDialogCommon.js/clean/editor/ui/dialogs/content/EdDialogCommon.js