You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/06/09 22:49:36 UTC

svn commit: r953154 - /myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js

Author: lu4242
Date: Wed Jun  9 20:49:36 2010
New Revision: 953154

URL: http://svn.apache.org/viewvc?rev=953154&view=rev
Log:
MYFACES-2748 NPE in htmlunit when testing ajax rendering (Thanks to Werner Punz for provide the patch)

Modified:
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js?rev=953154&r1=953153&r2=953154&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js Wed Jun  9 20:49:36 2010
@@ -173,12 +173,26 @@ myfaces._impl.core._Runtime.singletonExt
 
                 //now to the non w3c compliant browsers
                 //http://blogs.perl.org/users/clinton_gormley/2010/02/forcing-ie-to-accept-script-tags-in-innerhtml.html
+                //we have to cope with deficiencies between ie and its simulations in this case
+                var probe = document.createElement("div");
+                probe.innerHTML = "<table><div></div></table>";
+                var depth = 0;
+                while(probe) {
+                    probe = probe.childNodes[0];
+                    depth++;
+                }
+                depth--;
+
                 var dummyPlaceHolder = document.createElement("div");
 
                 //fortunately a table element also works which is less critical than form elements regarding
                 //the inner content
                 dummyPlaceHolder.innerHTML = "<table>" + markup + "</table>";
-                evalNode = dummyPlaceHolder.childNodes[0].childNodes[0].childNodes[0];
+                evalNode = dummyPlaceHolder;
+                for(var cnt = 0; cnt < depth; cnt++) {
+                    evalNode = evalNode.childNodes[0];
+                }
+
                 parentNode = item.parentNode;
                 item.parentNode.replaceChild(evalNode, item);