<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -67,7 +67,7 @@ load(&quot;build/runtest/env.js&quot;);
                 //allow unanticipated xhr error with no ajax.handleError 
                 //callback (eg jQuery.getScript) to exit gracefully
                 $env.onInterrupt = function(){
-                    ok(false, 'gracefully continuing test');
+                    $env.info('thread interupt: gracefully continuing test');
                     start();
                 };
                 </diff>
      <filename>bin/jquery-1.3.2-test.js</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@
 PROJECT: env-js
 BUILD_MAJOR: 1
 BUILD_MINOR: 0
-BUILD_ID: rc4
+BUILD_ID: rc5
 BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
 VERSION: ${BUILD} ${DSTAMP}
     </diff>
      <filename>build.properties</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 /*
- * Envjs env-js.1.0.rc4 
+ * Envjs env-js.1.0.rc5 
  * Pure JavaScript Browser Environment
  *   By John Resig &lt;http://ejohn.org/&gt;
  * Copyright 2008-2009 John Resig, under the MIT License
@@ -335,8 +335,7 @@ var __findItemIndex__ = function (nodelist, id) {
  * @param  refChildIndex : int     - the array index to insert the Node before
  */
 var __insertBefore__ = function(nodelist, newChild, refChildIndex) {
-    if ((refChildIndex &gt;= 0) &amp;&amp; (refChildIndex &lt; nodelist.length)) { // bounds check
-        
+    if ((refChildIndex &gt;= 0) &amp;&amp; (refChildIndex &lt;= nodelist.length)) { // bounds check
         if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) {  // node is a DocumentFragment
             // append the children of DocumentFragment
             Array.prototype.splice.apply(nodelist,[refChildIndex, 0].concat(newChild.childNodes.toArray()));
@@ -657,7 +656,6 @@ var __findNamedItemIndex__ = function(namednodemap, name, isnsmap) {
           break;
         }
     }else{
-        
         if (namednodemap[i].name.toLowerCase() == name.toLowerCase()) {         // found it!
           ret = i;
           break;
@@ -872,9 +870,13 @@ __extend__(DOMNode.prototype, {
     insertBefore : function(newChild, refChild) {
         var prevNode;
         
-        if(newChild==null || refChild==null){
+        if(newChild==null){
             return newChild;
         }
+        if(refChild==null){
+            this.appendChild(newChild);
+            return this.newChild;
+        }
         
         // test for exceptions
         if (__ownerDocument__(this).implementation.errorChecking) {
@@ -897,7 +899,6 @@ __extend__(DOMNode.prototype, {
         if (refChild) {                                // if refChild is specified, insert before it
             // find index of refChild
             var itemIndex = __findItemIndex__(this.childNodes, refChild._id);
-            
             // throw Exception if there is no child node with this id
             if (__ownerDocument__(this).implementation.errorChecking &amp;&amp; (itemIndex &lt; 0)) {
               throw(new DOMException(DOMException.NOT_FOUND_ERR));
@@ -911,8 +912,7 @@ __extend__(DOMNode.prototype, {
             }
             
             // insert newChild into childNodes
-            __insertBefore__(this.childNodes, newChild, 
-                __findItemIndex__(this.childNodes, refChild._id));
+            __insertBefore__(this.childNodes, newChild, itemIndex);
             
             // do node pointer surgery
             prevNode = refChild.previousSibling;
@@ -932,6 +932,7 @@ __extend__(DOMNode.prototype, {
                 newChild.parentNode = this;                // set the parentNode of the newChild
                 refChild.previousSibling = newChild;       // link refChild to newChild
             }
+            
         }else {                                         // otherwise, append to end
             prevNode = this.lastChild;
             this.appendChild(newChild);
@@ -2069,6 +2070,12 @@ __extend__(DOMProcessingInstruction.prototype, {
       // The content of this processing instruction.
         return this.nodeName;
     },
+    set target(value){
+      // The target of this processing instruction.
+      // XML defines this as being the first token following the markup that begins the processing instruction.
+      // The content of this processing instruction.
+        this.nodeName = value;
+    },
     get nodeType(){
         return DOMNode.PROCESSING_INSTRUCTION_NODE;
     },
@@ -2363,7 +2370,7 @@ XMLP.prototype.appendFragment = function(xmlfragment) {
 
 XMLP.prototype._parse = function() {
 
-        if(this.m_iP == this.m_xml.length) {
+    if(this.m_iP == this.m_xml.length) {
         return XMLP._NONE;
     }
 
@@ -2383,6 +2390,7 @@ XMLP.prototype._parse = function() {
             }
         }
         else{
+              
             return this._parseElement(this.m_iP + 1);
         }
     }
@@ -2390,6 +2398,7 @@ XMLP.prototype._parse = function() {
         return this._parseEntity(this.m_iP + 1);
     }
     else{
+          
         return this._parseText(this.m_iP);
     }
 
@@ -3695,7 +3704,8 @@ __extend__(DOMImplementation.prototype,{
  *
  * @return : DOMDocument
  */
-function __parseLoop__(impl, doc, p) {
+
+function __parseLoop__(impl, doc, p, isWindowDocument) {
     var iEvt, iNode, iAttr, strName;
     var iNodeParent = doc;
 
@@ -3712,10 +3722,11 @@ function __parseLoop__(impl, doc, p) {
     }
 
   // loop until SAX parser stops emitting events
+  var q = 0;
   while(true) {
     // get next event
     iEvt = p.next();
-
+    
     if (iEvt == XMLP._ELM_B) {                      // Begin-Element Event
       var pName = p.getName();                      // get the Element name
       pName = trim(pName, true, true);              // strip spaces from Element name
@@ -3724,7 +3735,6 @@ function __parseLoop__(impl, doc, p) {
 
       if (!impl.namespaceAware) {
         iNode = doc.createElement(p.getName());     // create the Element
-
         // add attributes to Element
         for(var i = 0; i &lt; p.getAttributeCount(); i++) {
           strName = p.getAttributeName(i);          // get Attribute name
@@ -3805,9 +3815,9 @@ function __parseLoop__(impl, doc, p) {
       iNodeParent = iNode;                          // descend one level of the DOM Tree
     }
 
-    else if(iEvt == XMLP._ELM_E) {                  // End-Element Event
-      __endHTMLElement__(iNodeParent, doc, p);
-      iNodeParent = iNodeParent.parentNode;         // ascend one level of the DOM Tree
+    else if(iEvt == XMLP._ELM_E) {                  // End-Element Event        
+        __endHTMLElement__(iNodeParent, doc, p);
+        iNodeParent = iNodeParent.parentNode;         // ascend one level of the DOM Tree
     }
 
     else if(iEvt == XMLP._ELM_EMP) {                // Empty Element Event
@@ -3893,7 +3903,6 @@ function __parseLoop__(impl, doc, p) {
         iNodeParent._documentElement = iNode;        // register this Element as the Document.documentElement
       }
 
-
       __endHTMLElement__(iNode, doc, p);
       iNodeParent.appendChild(iNode);               // attach Element to parentNode
     }
@@ -5126,8 +5135,8 @@ __extend__(HTMLElement.prototype, {
 		    
 	    },
 		set innerHTML(html){
-		    //$debug(&quot;htmlElement.innerHTML(&quot;+html+&quot;)&quot;);
 		    //Should be replaced with HTMLPARSER usage
+            //$debug('SETTING INNER HTML ('+this+'+'+html.substring(0,64));
 		    var doc = new DOMParser().
 			  parseFromString('&lt;div&gt;'+html+'&lt;/div&gt;');
             var parent = doc.documentElement;
@@ -8449,7 +8458,6 @@ XMLHttpRequest.prototype = {
 	setRequestHeader: function(header, value){
 		this.headers[header] = value;
 	},
-	getResponseHeader: function(header){ },
 	send: function(data){
 		var _this = this;
 		
@@ -8499,6 +8507,7 @@ XMLHttpRequest.prototype = {
 		//TODO
 	},
 	getResponseHeader: function(header){
+        $debug('GETTING RESPONSE HEADER '+header);
 	  var rHeader, returnedHeaders;
 		if (this.readyState &lt; 3){
 			throw new Error(&quot;INVALID_STATE_ERR&quot;);
@@ -8508,8 +8517,13 @@ XMLHttpRequest.prototype = {
 				if (rHeader.match(new RegExp(header, &quot;i&quot;)))
 					returnedHeaders.push(this.responseHeaders[rHeader]);
 			}
-			if (returnedHeaders.length){ return returnedHeaders.join(&quot;, &quot;); }
-		}return null;
+            
+			if (returnedHeaders.length){ 
+                $debug('GOT RESPONSE HEADER '+returnedHeaders.join(&quot;, &quot;));
+                return returnedHeaders.join(&quot;, &quot;); 
+            }
+		}
+        return null;
 	},
 	getAllResponseHeaders: function(){
 	  var header, returnedHeaders = [];</diff>
      <filename>dist/env.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 /*
- * Envjs env-js.1.0.rc4 
+ * Envjs env-js.1.0.rc5 
  * Pure JavaScript Browser Environment
  *   By John Resig &lt;http://ejohn.org/&gt;
  * Copyright 2008-2009 John Resig, under the MIT License
@@ -41,6 +41,8 @@ var Envjs = function(){
     $env.warn   = function(){};
     $env.error  = function(){};
     
+    
+    $env.debugParser = false;
     //uncomment these if you want to get some internal log statementes
     /*$env.debug  = function(msg){
         $env.log(msg,&quot;DEBUG&quot;); 
@@ -306,7 +308,7 @@ var Envjs = function(){
                         run.apply(_this);
                     }
                 }catch(e){
-                    $env.warn(&quot;interuption running timed function&quot;);
+                    $env.debug(&quot;interuption running timed function&quot;);
                     _this.stop();
                     $env.onInterrupt();
                 };
@@ -398,6 +400,27 @@ var Envjs = function(){
                 } else {
                     connection = url.openConnection();
                     connection.connect();
+                    //try to add some canned headers that make sense
+                    
+                    try{
+                        if(xhr.url.match(/html$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/html';
+                        }else if(xhr.url.match(/.xml$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/xml';
+                        }else if(xhr.url.match(/.js$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/javascript';
+                        }else if(xhr.url.match(/.json$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'application/json';
+                        }else{
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/plain';
+                        }
+                    //xhr.responseHeaders['Last-Modified'] = connection.getLastModified();
+                    //xhr.responseHeaders['Content-Length'] = headerValue+'';
+                    //xhr.responseHeaders['Date'] = new Date()+'';*/
+                    }catch(e){
+                        $env.error('failed to load response headers',e);
+                    }
+                    	
                 }
             }catch(e){
                 $env.error('failed to open file '+ url, e);
@@ -430,45 +453,50 @@ var Envjs = function(){
 			}
 			
             
-            var respheadlength = connection.getHeaderFields().size();
-            // Stick the response headers into responseHeaders
-            for (var i = 0; i &lt; respheadlength; i++) { 
-                var headerName = connection.getHeaderFieldKey(i); 
-                var headerValue = connection.getHeaderField(i); 
-                if (headerName)
-                    xhr.responseHeaders[headerName+''] = headerValue+'';
-            }
         }
         if(connection){
-                xhr.readyState = 4;
-                xhr.status = parseInt(connection.responseCode,10) || undefined;
-                xhr.statusText = connection.responseMessage || &quot;&quot;;
-                
-                var contentEncoding = connection.getContentEncoding() || &quot;utf-8&quot;,
-                    baos = new java.io.ByteArrayOutputStream(),
-                    buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024),
-                    length,
-                    stream = null,
-                    responseXML = null;
-
-                try{
-                    stream = (contentEncoding.equalsIgnoreCase(&quot;gzip&quot;) || contentEncoding.equalsIgnoreCase(&quot;decompress&quot;) )?
-                            new java.util.zip.GZIPInputStream(connection.getInputStream()) :
-                            connection.getInputStream();
-                }catch(e){
-                    $env.error('failed to open connection stream \n'+e.toString(), e);
-                    stream = connection.getErrorStream();
-                }
-                
-                while ((length = stream.read(buffer)) != -1) {
-                    baos.write(buffer, 0, length);
+            try{
+                var respheadlength = connection.getHeaderFields().size();
+                // Stick the response headers into responseHeaders
+                for (var i = 0; i &lt; respheadlength; i++) { 
+                    var headerName = connection.getHeaderFieldKey(i); 
+                    var headerValue = connection.getHeaderField(i); 
+                    if (headerName)
+                        xhr.responseHeaders[headerName+''] = headerValue+'';
                 }
+            }catch(e){
+                $env.error('failed to load response headers',e);
+            }
+            
+            xhr.readyState = 4;
+            xhr.status = parseInt(connection.responseCode,10) || undefined;
+            xhr.statusText = connection.responseMessage || &quot;&quot;;
+            
+            var contentEncoding = connection.getContentEncoding() || &quot;utf-8&quot;,
+                baos = new java.io.ByteArrayOutputStream(),
+                buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024),
+                length,
+                stream = null,
+                responseXML = null;
 
-                baos.close();
-                stream.close();
+            try{
+                stream = (contentEncoding.equalsIgnoreCase(&quot;gzip&quot;) || contentEncoding.equalsIgnoreCase(&quot;decompress&quot;) )?
+                        new java.util.zip.GZIPInputStream(connection.getInputStream()) :
+                        connection.getInputStream();
+            }catch(e){
+                $env.error('failed to open connection stream \n'+e.toString(), e);
+                stream = connection.getErrorStream();
+            }
+            
+            while ((length = stream.read(buffer)) != -1) {
+                baos.write(buffer, 0, length);
+            }
 
-                xhr.responseText = java.nio.charset.Charset.forName(&quot;UTF-8&quot;).
-                    decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+&quot;&quot;;
+            baos.close();
+            stream.close();
+
+            xhr.responseText = java.nio.charset.Charset.forName(&quot;UTF-8&quot;).
+                decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+&quot;&quot;;
                 
         }
         if(responseHandler){
@@ -601,7 +629,7 @@ var Envjs = function(){
     $env.restoreScope = restoreScope;
     
 })(Envjs);/*
- * Envjs env-js.1.0.rc4 
+ * Envjs env-js.1.0.rc5 
  * Pure JavaScript Browser Environment
  *   By John Resig &lt;http://ejohn.org/&gt;
  * Copyright 2008-2009 John Resig, under the MIT License
@@ -937,8 +965,7 @@ var __findItemIndex__ = function (nodelist, id) {
  * @param  refChildIndex : int     - the array index to insert the Node before
  */
 var __insertBefore__ = function(nodelist, newChild, refChildIndex) {
-    if ((refChildIndex &gt;= 0) &amp;&amp; (refChildIndex &lt; nodelist.length)) { // bounds check
-        
+    if ((refChildIndex &gt;= 0) &amp;&amp; (refChildIndex &lt;= nodelist.length)) { // bounds check
         if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) {  // node is a DocumentFragment
             // append the children of DocumentFragment
             Array.prototype.splice.apply(nodelist,[refChildIndex, 0].concat(newChild.childNodes.toArray()));
@@ -1259,7 +1286,6 @@ var __findNamedItemIndex__ = function(namednodemap, name, isnsmap) {
           break;
         }
     }else{
-        
         if (namednodemap[i].name.toLowerCase() == name.toLowerCase()) {         // found it!
           ret = i;
           break;
@@ -1474,9 +1500,13 @@ __extend__(DOMNode.prototype, {
     insertBefore : function(newChild, refChild) {
         var prevNode;
         
-        if(newChild==null || refChild==null){
+        if(newChild==null){
             return newChild;
         }
+        if(refChild==null){
+            this.appendChild(newChild);
+            return this.newChild;
+        }
         
         // test for exceptions
         if (__ownerDocument__(this).implementation.errorChecking) {
@@ -1499,7 +1529,6 @@ __extend__(DOMNode.prototype, {
         if (refChild) {                                // if refChild is specified, insert before it
             // find index of refChild
             var itemIndex = __findItemIndex__(this.childNodes, refChild._id);
-            
             // throw Exception if there is no child node with this id
             if (__ownerDocument__(this).implementation.errorChecking &amp;&amp; (itemIndex &lt; 0)) {
               throw(new DOMException(DOMException.NOT_FOUND_ERR));
@@ -1513,8 +1542,7 @@ __extend__(DOMNode.prototype, {
             }
             
             // insert newChild into childNodes
-            __insertBefore__(this.childNodes, newChild, 
-                __findItemIndex__(this.childNodes, refChild._id));
+            __insertBefore__(this.childNodes, newChild, itemIndex);
             
             // do node pointer surgery
             prevNode = refChild.previousSibling;
@@ -1534,6 +1562,7 @@ __extend__(DOMNode.prototype, {
                 newChild.parentNode = this;                // set the parentNode of the newChild
                 refChild.previousSibling = newChild;       // link refChild to newChild
             }
+            
         }else {                                         // otherwise, append to end
             prevNode = this.lastChild;
             this.appendChild(newChild);
@@ -2671,6 +2700,12 @@ __extend__(DOMProcessingInstruction.prototype, {
       // The content of this processing instruction.
         return this.nodeName;
     },
+    set target(value){
+      // The target of this processing instruction.
+      // XML defines this as being the first token following the markup that begins the processing instruction.
+      // The content of this processing instruction.
+        this.nodeName = value;
+    },
     get nodeType(){
         return DOMNode.PROCESSING_INSTRUCTION_NODE;
     },
@@ -2965,7 +3000,7 @@ XMLP.prototype.appendFragment = function(xmlfragment) {
 
 XMLP.prototype._parse = function() {
 
-        if(this.m_iP == this.m_xml.length) {
+    if(this.m_iP == this.m_xml.length) {
         return XMLP._NONE;
     }
 
@@ -2985,6 +3020,7 @@ XMLP.prototype._parse = function() {
             }
         }
         else{
+              
             return this._parseElement(this.m_iP + 1);
         }
     }
@@ -2992,6 +3028,7 @@ XMLP.prototype._parse = function() {
         return this._parseEntity(this.m_iP + 1);
     }
     else{
+          
         return this._parseText(this.m_iP);
     }
 
@@ -4297,7 +4334,8 @@ __extend__(DOMImplementation.prototype,{
  *
  * @return : DOMDocument
  */
-function __parseLoop__(impl, doc, p) {
+
+function __parseLoop__(impl, doc, p, isWindowDocument) {
     var iEvt, iNode, iAttr, strName;
     var iNodeParent = doc;
 
@@ -4314,10 +4352,11 @@ function __parseLoop__(impl, doc, p) {
     }
 
   // loop until SAX parser stops emitting events
+  var q = 0;
   while(true) {
     // get next event
     iEvt = p.next();
-
+    
     if (iEvt == XMLP._ELM_B) {                      // Begin-Element Event
       var pName = p.getName();                      // get the Element name
       pName = trim(pName, true, true);              // strip spaces from Element name
@@ -4326,7 +4365,6 @@ function __parseLoop__(impl, doc, p) {
 
       if (!impl.namespaceAware) {
         iNode = doc.createElement(p.getName());     // create the Element
-
         // add attributes to Element
         for(var i = 0; i &lt; p.getAttributeCount(); i++) {
           strName = p.getAttributeName(i);          // get Attribute name
@@ -4407,9 +4445,9 @@ function __parseLoop__(impl, doc, p) {
       iNodeParent = iNode;                          // descend one level of the DOM Tree
     }
 
-    else if(iEvt == XMLP._ELM_E) {                  // End-Element Event
-      __endHTMLElement__(iNodeParent, doc, p);
-      iNodeParent = iNodeParent.parentNode;         // ascend one level of the DOM Tree
+    else if(iEvt == XMLP._ELM_E) {                  // End-Element Event        
+        __endHTMLElement__(iNodeParent, doc, p);
+        iNodeParent = iNodeParent.parentNode;         // ascend one level of the DOM Tree
     }
 
     else if(iEvt == XMLP._ELM_EMP) {                // Empty Element Event
@@ -4495,7 +4533,6 @@ function __parseLoop__(impl, doc, p) {
         iNodeParent._documentElement = iNode;        // register this Element as the Document.documentElement
       }
 
-
       __endHTMLElement__(iNode, doc, p);
       iNodeParent.appendChild(iNode);               // attach Element to parentNode
     }
@@ -5728,8 +5765,8 @@ __extend__(HTMLElement.prototype, {
 		    
 	    },
 		set innerHTML(html){
-		    //$debug(&quot;htmlElement.innerHTML(&quot;+html+&quot;)&quot;);
 		    //Should be replaced with HTMLPARSER usage
+            //$debug('SETTING INNER HTML ('+this+'+'+html.substring(0,64));
 		    var doc = new DOMParser().
 			  parseFromString('&lt;div&gt;'+html+'&lt;/div&gt;');
             var parent = doc.documentElement;
@@ -9051,7 +9088,6 @@ XMLHttpRequest.prototype = {
 	setRequestHeader: function(header, value){
 		this.headers[header] = value;
 	},
-	getResponseHeader: function(header){ },
 	send: function(data){
 		var _this = this;
 		
@@ -9101,6 +9137,7 @@ XMLHttpRequest.prototype = {
 		//TODO
 	},
 	getResponseHeader: function(header){
+        $debug('GETTING RESPONSE HEADER '+header);
 	  var rHeader, returnedHeaders;
 		if (this.readyState &lt; 3){
 			throw new Error(&quot;INVALID_STATE_ERR&quot;);
@@ -9110,8 +9147,13 @@ XMLHttpRequest.prototype = {
 				if (rHeader.match(new RegExp(header, &quot;i&quot;)))
 					returnedHeaders.push(this.responseHeaders[rHeader]);
 			}
-			if (returnedHeaders.length){ return returnedHeaders.join(&quot;, &quot;); }
-		}return null;
+            
+			if (returnedHeaders.length){ 
+                $debug('GOT RESPONSE HEADER '+returnedHeaders.join(&quot;, &quot;));
+                return returnedHeaders.join(&quot;, &quot;); 
+            }
+		}
+        return null;
 	},
 	getAllResponseHeaders: function(){
 	  var header, returnedHeaders = [];</diff>
      <filename>dist/env.rhino.js</filename>
    </modified>
    <modified>
      <diff>@@ -17,6 +17,13 @@
 
 5) Note the date and your email here.
 
+
+== 2009-08-18: thatcher.christopher@gmail.com ==
+(ran against github.com/thatcher/env-js)
+
+jQuery 1.3.2:
+* 1346 tests of 1471 passed, 125 failed.
+
 == 2009-08-18: thatcher.christopher@gmail.com ==
 (ran against github.com/thatcher/env-js)
 </diff>
      <filename>doc/jquery-compatibility.txt</filename>
    </modified>
    <modified>
      <diff>@@ -170,7 +170,8 @@ __extend__(DOMImplementation.prototype,{
  *
  * @return : DOMDocument
  */
-function __parseLoop__(impl, doc, p) {
+
+function __parseLoop__(impl, doc, p, isWindowDocument) {
     var iEvt, iNode, iAttr, strName;
     var iNodeParent = doc;
 
@@ -187,10 +188,11 @@ function __parseLoop__(impl, doc, p) {
     }
 
   // loop until SAX parser stops emitting events
+  var q = 0;
   while(true) {
     // get next event
     iEvt = p.next();
-
+    
     if (iEvt == XMLP._ELM_B) {                      // Begin-Element Event
       var pName = p.getName();                      // get the Element name
       pName = trim(pName, true, true);              // strip spaces from Element name
@@ -199,7 +201,6 @@ function __parseLoop__(impl, doc, p) {
 
       if (!impl.namespaceAware) {
         iNode = doc.createElement(p.getName());     // create the Element
-
         // add attributes to Element
         for(var i = 0; i &lt; p.getAttributeCount(); i++) {
           strName = p.getAttributeName(i);          // get Attribute name
@@ -280,9 +281,9 @@ function __parseLoop__(impl, doc, p) {
       iNodeParent = iNode;                          // descend one level of the DOM Tree
     }
 
-    else if(iEvt == XMLP._ELM_E) {                  // End-Element Event
-      __endHTMLElement__(iNodeParent, doc, p);
-      iNodeParent = iNodeParent.parentNode;         // ascend one level of the DOM Tree
+    else if(iEvt == XMLP._ELM_E) {                  // End-Element Event        
+        __endHTMLElement__(iNodeParent, doc, p);
+        iNodeParent = iNodeParent.parentNode;         // ascend one level of the DOM Tree
     }
 
     else if(iEvt == XMLP._ELM_EMP) {                // Empty Element Event
@@ -368,7 +369,6 @@ function __parseLoop__(impl, doc, p) {
         iNodeParent._documentElement = iNode;        // register this Element as the Document.documentElement
       }
 
-
       __endHTMLElement__(iNode, doc, p);
       iNodeParent.appendChild(iNode);               // attach Element to parentNode
     }</diff>
      <filename>src/dom/implementation.js</filename>
    </modified>
    <modified>
      <diff>@@ -31,6 +31,12 @@ __extend__(DOMProcessingInstruction.prototype, {
       // The content of this processing instruction.
         return this.nodeName;
     },
+    set target(value){
+      // The target of this processing instruction.
+      // XML defines this as being the first token following the markup that begins the processing instruction.
+      // The content of this processing instruction.
+        this.nodeName = value;
+    },
     get nodeType(){
         return DOMNode.PROCESSING_INSTRUCTION_NODE;
     },</diff>
      <filename>src/dom/instruction.js</filename>
    </modified>
    <modified>
      <diff>@@ -218,7 +218,6 @@ var __findNamedItemIndex__ = function(namednodemap, name, isnsmap) {
           break;
         }
     }else{
-        
         if (namednodemap[i].name.toLowerCase() == name.toLowerCase()) {         // found it!
           ret = i;
           break;</diff>
      <filename>src/dom/namednodemap.js</filename>
    </modified>
    <modified>
      <diff>@@ -68,9 +68,13 @@ __extend__(DOMNode.prototype, {
     insertBefore : function(newChild, refChild) {
         var prevNode;
         
-        if(newChild==null || refChild==null){
+        if(newChild==null){
             return newChild;
         }
+        if(refChild==null){
+            this.appendChild(newChild);
+            return this.newChild;
+        }
         
         // test for exceptions
         if (__ownerDocument__(this).implementation.errorChecking) {
@@ -93,7 +97,6 @@ __extend__(DOMNode.prototype, {
         if (refChild) {                                // if refChild is specified, insert before it
             // find index of refChild
             var itemIndex = __findItemIndex__(this.childNodes, refChild._id);
-            
             // throw Exception if there is no child node with this id
             if (__ownerDocument__(this).implementation.errorChecking &amp;&amp; (itemIndex &lt; 0)) {
               throw(new DOMException(DOMException.NOT_FOUND_ERR));
@@ -107,8 +110,7 @@ __extend__(DOMNode.prototype, {
             }
             
             // insert newChild into childNodes
-            __insertBefore__(this.childNodes, newChild, 
-                __findItemIndex__(this.childNodes, refChild._id));
+            __insertBefore__(this.childNodes, newChild, itemIndex);
             
             // do node pointer surgery
             prevNode = refChild.previousSibling;
@@ -128,6 +130,7 @@ __extend__(DOMNode.prototype, {
                 newChild.parentNode = this;                // set the parentNode of the newChild
                 refChild.previousSibling = newChild;       // link refChild to newChild
             }
+            
         }else {                                         // otherwise, append to end
             prevNode = this.lastChild;
             this.appendChild(newChild);</diff>
      <filename>src/dom/node.js</filename>
    </modified>
    <modified>
      <diff>@@ -92,8 +92,7 @@ var __findItemIndex__ = function (nodelist, id) {
  * @param  refChildIndex : int     - the array index to insert the Node before
  */
 var __insertBefore__ = function(nodelist, newChild, refChildIndex) {
-    if ((refChildIndex &gt;= 0) &amp;&amp; (refChildIndex &lt; nodelist.length)) { // bounds check
-        
+    if ((refChildIndex &gt;= 0) &amp;&amp; (refChildIndex &lt;= nodelist.length)) { // bounds check
         if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) {  // node is a DocumentFragment
             // append the children of DocumentFragment
             Array.prototype.splice.apply(nodelist,[refChildIndex, 0].concat(newChild.childNodes.toArray()));</diff>
      <filename>src/dom/nodelist.js</filename>
    </modified>
    <modified>
      <diff>@@ -280,7 +280,7 @@ XMLP.prototype.appendFragment = function(xmlfragment) {
 
 XMLP.prototype._parse = function() {
 
-        if(this.m_iP == this.m_xml.length) {
+    if(this.m_iP == this.m_xml.length) {
         return XMLP._NONE;
     }
 
@@ -300,6 +300,7 @@ XMLP.prototype._parse = function() {
             }
         }
         else{
+              
             return this._parseElement(this.m_iP + 1);
         }
     }
@@ -307,6 +308,7 @@ XMLP.prototype._parse = function() {
         return this._parseEntity(this.m_iP + 1);
     }
     else{
+          
         return this._parseText(this.m_iP);
     }
 </diff>
      <filename>src/dom/parser.js</filename>
    </modified>
    <modified>
      <diff>@@ -38,8 +38,8 @@ __extend__(HTMLElement.prototype, {
 		    
 	    },
 		set innerHTML(html){
-		    //$debug(&quot;htmlElement.innerHTML(&quot;+html+&quot;)&quot;);
 		    //Should be replaced with HTMLPARSER usage
+            //$debug('SETTING INNER HTML ('+this+'+'+html.substring(0,64));
 		    var doc = new DOMParser().
 			  parseFromString('&lt;div&gt;'+html+'&lt;/div&gt;');
             var parent = doc.documentElement;</diff>
      <filename>src/html/element.js</filename>
    </modified>
    <modified>
      <diff>@@ -36,6 +36,8 @@ var Envjs = function(){
     $env.warn   = function(){};
     $env.error  = function(){};
     
+    
+    $env.debugParser = false;
     //uncomment these if you want to get some internal log statementes
     /*$env.debug  = function(msg){
         $env.log(msg,&quot;DEBUG&quot;); </diff>
      <filename>src/platform/core.js</filename>
    </modified>
    <modified>
      <diff>@@ -54,7 +54,7 @@
                         run.apply(_this);
                     }
                 }catch(e){
-                    $env.warn(&quot;interuption running timed function&quot;);
+                    $env.debug(&quot;interuption running timed function&quot;);
                     _this.stop();
                     $env.onInterrupt();
                 };
@@ -146,6 +146,27 @@
                 } else {
                     connection = url.openConnection();
                     connection.connect();
+                    //try to add some canned headers that make sense
+                    
+                    try{
+                        if(xhr.url.match(/html$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/html';
+                        }else if(xhr.url.match(/.xml$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/xml';
+                        }else if(xhr.url.match(/.js$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/javascript';
+                        }else if(xhr.url.match(/.json$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'application/json';
+                        }else{
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/plain';
+                        }
+                    //xhr.responseHeaders['Last-Modified'] = connection.getLastModified();
+                    //xhr.responseHeaders['Content-Length'] = headerValue+'';
+                    //xhr.responseHeaders['Date'] = new Date()+'';*/
+                    }catch(e){
+                        $env.error('failed to load response headers',e);
+                    }
+                    	
                 }
             }catch(e){
                 $env.error('failed to open file '+ url, e);
@@ -178,45 +199,50 @@
 			}
 			
             
-            var respheadlength = connection.getHeaderFields().size();
-            // Stick the response headers into responseHeaders
-            for (var i = 0; i &lt; respheadlength; i++) { 
-                var headerName = connection.getHeaderFieldKey(i); 
-                var headerValue = connection.getHeaderField(i); 
-                if (headerName)
-                    xhr.responseHeaders[headerName+''] = headerValue+'';
-            }
         }
         if(connection){
-                xhr.readyState = 4;
-                xhr.status = parseInt(connection.responseCode,10) || undefined;
-                xhr.statusText = connection.responseMessage || &quot;&quot;;
-                
-                var contentEncoding = connection.getContentEncoding() || &quot;utf-8&quot;,
-                    baos = new java.io.ByteArrayOutputStream(),
-                    buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024),
-                    length,
-                    stream = null,
-                    responseXML = null;
-
-                try{
-                    stream = (contentEncoding.equalsIgnoreCase(&quot;gzip&quot;) || contentEncoding.equalsIgnoreCase(&quot;decompress&quot;) )?
-                            new java.util.zip.GZIPInputStream(connection.getInputStream()) :
-                            connection.getInputStream();
-                }catch(e){
-                    $env.error('failed to open connection stream \n'+e.toString(), e);
-                    stream = connection.getErrorStream();
-                }
-                
-                while ((length = stream.read(buffer)) != -1) {
-                    baos.write(buffer, 0, length);
+            try{
+                var respheadlength = connection.getHeaderFields().size();
+                // Stick the response headers into responseHeaders
+                for (var i = 0; i &lt; respheadlength; i++) { 
+                    var headerName = connection.getHeaderFieldKey(i); 
+                    var headerValue = connection.getHeaderField(i); 
+                    if (headerName)
+                        xhr.responseHeaders[headerName+''] = headerValue+'';
                 }
+            }catch(e){
+                $env.error('failed to load response headers',e);
+            }
+            
+            xhr.readyState = 4;
+            xhr.status = parseInt(connection.responseCode,10) || undefined;
+            xhr.statusText = connection.responseMessage || &quot;&quot;;
+            
+            var contentEncoding = connection.getContentEncoding() || &quot;utf-8&quot;,
+                baos = new java.io.ByteArrayOutputStream(),
+                buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024),
+                length,
+                stream = null,
+                responseXML = null;
+
+            try{
+                stream = (contentEncoding.equalsIgnoreCase(&quot;gzip&quot;) || contentEncoding.equalsIgnoreCase(&quot;decompress&quot;) )?
+                        new java.util.zip.GZIPInputStream(connection.getInputStream()) :
+                        connection.getInputStream();
+            }catch(e){
+                $env.error('failed to open connection stream \n'+e.toString(), e);
+                stream = connection.getErrorStream();
+            }
+            
+            while ((length = stream.read(buffer)) != -1) {
+                baos.write(buffer, 0, length);
+            }
 
-                baos.close();
-                stream.close();
+            baos.close();
+            stream.close();
 
-                xhr.responseText = java.nio.charset.Charset.forName(&quot;UTF-8&quot;).
-                    decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+&quot;&quot;;
+            xhr.responseText = java.nio.charset.Charset.forName(&quot;UTF-8&quot;).
+                decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+&quot;&quot;;
                 
         }
         if(responseHandler){</diff>
      <filename>src/platform/rhino.js</filename>
    </modified>
    <modified>
      <diff>@@ -23,7 +23,6 @@ XMLHttpRequest.prototype = {
 	setRequestHeader: function(header, value){
 		this.headers[header] = value;
 	},
-	getResponseHeader: function(header){ },
 	send: function(data){
 		var _this = this;
 		
@@ -73,6 +72,7 @@ XMLHttpRequest.prototype = {
 		//TODO
 	},
 	getResponseHeader: function(header){
+        $debug('GETTING RESPONSE HEADER '+header);
 	  var rHeader, returnedHeaders;
 		if (this.readyState &lt; 3){
 			throw new Error(&quot;INVALID_STATE_ERR&quot;);
@@ -82,8 +82,13 @@ XMLHttpRequest.prototype = {
 				if (rHeader.match(new RegExp(header, &quot;i&quot;)))
 					returnedHeaders.push(this.responseHeaders[rHeader]);
 			}
-			if (returnedHeaders.length){ return returnedHeaders.join(&quot;, &quot;); }
-		}return null;
+            
+			if (returnedHeaders.length){ 
+                $debug('GOT RESPONSE HEADER '+returnedHeaders.join(&quot;, &quot;));
+                return returnedHeaders.join(&quot;, &quot;); 
+            }
+		}
+        return null;
 	},
 	getAllResponseHeaders: function(){
 	  var header, returnedHeaders = [];</diff>
      <filename>src/window/xhr.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>07617fa351c31cfa6418394c4103a04f37ef9d2f</id>
    </parent>
  </parents>
  <author>
    <name>thatcher</name>
    <email>thatcher@christopher-thatchers-macbook-air.local</email>
  </author>
  <url>http://github.com/thatcher/env-js/commit/1f654422ba30bc5468e25e611878cc8ec7ed89f2</url>
  <id>1f654422ba30bc5468e25e611878cc8ec7ed89f2</id>
  <committed-date>2009-08-20T07:26:23-07:00</committed-date>
  <authored-date>2009-08-20T07:26:23-07:00</authored-date>
  <message>found some good little bugs in node insertBefore, also now if using ajax to GET local files, some attempt to fake common response headers is made.  prevents jquery from assuming xml doc is html doc and injecting it into the dom, etc.  rc5 : 1346 tests are passing in jquery 1.3.2 now</message>
  <tree>3f4f94bb04eb20e4341756827e2339c8ac584932</tree>
  <committer>
    <name>thatcher</name>
    <email>thatcher@christopher-thatchers-macbook-air.local</email>
  </committer>
</commit>
