From richfaces-svn-commits at lists.jboss.org Sun Apr 26 14:21:23 2009 Content-Type: multipart/mixed; boundary="===============6231155490176953701==" MIME-Version: 1.0 From: richfaces-svn-commits at lists.jboss.org To: richfaces-svn-commits at lists.jboss.org Subject: [richfaces-svn-commits] JBoss Rich Faces SVN: r13880 - trunk/framework/impl/src/main/javascript/ajaxjsf. Date: Sun, 26 Apr 2009 14:20:28 -0400 Message-ID: --===============6231155490176953701== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: nbelaevski Date: 2009-04-26 14:20:23 -0400 (Sun, 26 Apr 2009) New Revision: 13880 Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js Log: https://jira.jboss.org/jira/browse/RF-6910 Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2009-04-26 = 14:47:12 UTC (rev 13879) +++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2009-04-26 = 18:20:23 UTC (rev 13880) @@ -391,10 +391,50 @@ } else { // need to check for firstChild due to opera 8 bug with hasChildNodes Sarissa.clearChildNodes(oldnode); - var importednode =3D window.document.importNode(newnode, true); + = + var importednode =3D window.document.importNode(newnode, true); //importednode.innerHTML =3D importednode.innerHTML; = LOG.debug("Replace content of node by replaceChild()"); - anchor.replaceChild(importednode,oldnode); + + var oldGetElementById =3D null; + = + A4J.AJAX.TestReplacedGetElementByIdVisibility(); + if (!A4J.AJAX._testReplacedGetElementByIdVisibility) { + LOG.debug("Temporarily substituting document.getElementById() to work= around WebKit issue"); + oldGetElementById =3D document.getElementById; + document.getElementById =3D function(id) { + var elt =3D oldGetElementById.apply(document, arguments); + if (!elt) { + var id =3D arguments[0]; + + LOG.debug("Element [@id=3D'" + id + "'] was not found in document, = trying to locate XPath match"); + = + try { + var result =3D importednode.ownerDocument.evaluate("//*[@id=3D'" += id + "']", = + importednode, null, XPathResult.ANY_UNORDERED_NODE_TYPE); + = + if (result) { + elt =3D result.singleNodeValue; + } + = + LOG.debug("XPath located: " + elt); + } catch (e) { + LOG.error("Error locating [@id=3D'" + id + "'] element: " + e.mess= age); + } + } + = + return elt; + }; + } + = + try { + anchor.replaceChild(importednode,oldnode); + } finally { + if (oldGetElementById) { + LOG.debug("Restoring document.getElementById()"); + document.getElementById =3D oldGetElementById; + } + } } = = // re-execute all script fragments in imported subtree... @@ -1733,3 +1773,30 @@ } A4J.AJAX._scriptTested =3D true; } + +A4J.AJAX.TestReplacedGetElementByIdVisibility =3D function() { + if (!A4J.AJAX._replacedGetElementByIdVisibilityTested) { + A4J.AJAX._replacedGetElementByIdVisibilityTested =3D true; + + A4J.AJAX.TestScriptEvaluation(); + if (A4J.AJAX._scriptEvaluated) { + try { + A4J.AJAX._testReplacedGetElementByIdVisibility =3D true; + = + var _span =3D document.createElement("span"); + document.body.appendChild(_span); + + var xmlString =3D "A4J.AJAX._= testReplacedGetElementByIdVisibility =3D !!(document.getElementById('_A4J_A= JAX_TestReplacedGetElementByIdVisibility'));"; + oDomDoc =3D (new DOMParser()).parseFromString(xmlString, "text/xml"); + var _newSpan =3D oDomDoc.getElementsByTagName("span")[0]; + + var importednode; + importednode =3D window.document.importNode(_newSpan, true); + document.body.replaceChild(importednode,_span); + document.body.removeChild(importednode); + } catch (e) { + LOG.error("Error testing replaced elements getElementById() visibility= : " + e.message); + } + } + } +}; --===============6231155490176953701==--