rem: range.setStart(legendElement, 0); range.setEnd(legendElement, legendElement.childNodes.length); 
add: range.selectNode(legendElement); 
context: function Startup(){  var editor = GetCurrentEditor();  if (!editor)  {    dump("Failed to get active editor!\n");    window.close();    return;  }  gDialog.editText = document.getElementById("EditText");  gDialog.legendText = document.getElementById("LegendText");  gDialog.legendAlign = document.getElementById("LegendAlign");  gDialog.RemoveFieldSet = document.getElementById("RemoveFieldSet");  // Get a single selected field set element  const kTagName = "fieldset";  try {    // Find a selected fieldset, or if one is at start or end of selection.    fieldsetElement = editor.getSelectedElement(kTagName);    if (!fieldsetElement)      fieldsetElement = editor.getElementOrParentBykTagName(kTagName, editor.selection.anchorNode);    if (!fieldsetElement)      fieldsetElement = editor.getElementOrParentBykTagName(kTagName, editor.selection.focusNode);  } catch (e) {}  if (fieldsetElement)    // We found an element and don't need to insert one    insertNew = false;  else  {    insertNew = true;    // We don't have an element selected,    //  so create one with default attributes    try {      fieldsetElement = editor.createElementWithDefaults(kTagName);    } catch (e) {}    if (!fieldsetElement)    {      dump("Failed to get selected element or create a new one!\n");      window.close();      return;    }    // Hide button removing existing fieldset    gDialog.RemoveFieldSet.hidden = true;  }  legendElement = fieldsetElement.firstChild;  if (legendElement && legendElement.localName == "LEGEND")  {    newLegend = false;    var range = editor.document.createRange();    range.setStart(legendElement, 0);    range.setEnd(legendElement, legendElement.childNodes.length);    gDialog.legendText.value = range.toString();    if (/</.test(legendElement.innerHTML))    {      gDialog.editText.checked = false;      gDialog.editText.disabled = false;      gDialog.legendText.disabled = true;      gDialog.editText.addEventListener("command", onEditText, false);      gDialog.RemoveFieldSet.focus();    }    else      SetTextboxFocus(gDialog.legendText);  }  else  {    newLegend = true;    // We don't have an element selected,    //  so create one with default attributes    legendElement = editor.createElementWithDefaults("legend");    if (!legendElement)    {      dump("Failed to get selected element or create a new one!\n");      window.close();      return;    }    SetTextboxFocus(gDialog.legendText);  }  // Make a copy to use for AdvancedEdit  globalElement = legendElement.cloneNode(false);  InitDialog();  SetWindowLocation();}
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/161212bb0026cff780d4cc07e50d7cf54d70e70b/EdFieldSetProps.js/buggy/editor/ui/dialogs/content/EdFieldSetProps.js