context: function _replaceDocument(tree) {  DEBUG.assert(tree != null, "Null tree passed to _replaceDocument");  DEBUG.assert(tree[0][0] == "ELEMENT" || tree[0][0] == "TEXT",               "Top-level expression was not XML")  tree = _XmlToDomNodes(tree);  // save here  var _saved_fieldvals = [];  var inputFields = document.getElementsByTagName("input");  for (var i = 0; i < inputFields.length; i++) {      var current = inputFields[i];     if(current.id != null && current.id != "") // only store fields with an id!       _saved_fieldvals.push({'field' : current.id, 'value' : current.value});  }  // delete the DOM except for the html tag and the body  // [IE] IE doesn't allow these tags to be deleted  var d = document.documentElement;  var body;  while(d.hasChildNodes()) {    if(isElementWithTag(d.firstChild, 'body')) {      body = d.firstChild;      var bodyLength = body.childNodes.length;      while (body.hasChildNodes()) {        body.removeChild(body.firstChild);      }      break; // [IE] no more nodes allowed after the body    }    d.removeChild(d.firstChild);  }  // insert new dom nodes  for (var p = tree[0].firstChild; p != null; p = p.nextSibling) {    if(isElementWithTag(p, 'body')) {     // insert body nodes inside the existing body node      for (var q = p.firstChild; q != null; q = q.nextSibling) {        var it = q.cloneNode(true);        body.appendChild(it);        _activateHandlers(it);      }      break; // [IE] no more nodes allowed after the body    }    var it = p.cloneNode(true);    d.insertBefore(it, body);    _activateHandlers(it);  }  // [IE]  //   hack to activate a style element in IE  _activateStyleElement();  // restore here  for (var i = 0; i < _saved_fieldvals.length; i++) {      var current = _saved_fieldvals[i];     var elem = document.getElementById(current.field);     if (elem) {        elem.value = current.value;      }  }    // hmm.  _focus();  return {};}
meta: 3249	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/3249/d5aa69f6436ef6b0cf920d77125ff5ecce5a8832/jslib.js/buggy/lib/js/jslib.js