From richfaces-svn-commits at lists.jboss.org Tue Mar 3 18:53:46 2009 Content-Type: multipart/mixed; boundary="===============3922100244648576050==" 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: r12815 - trunk/framework/impl/src/main/javascript/ajaxjsf. Date: Tue, 03 Mar 2009 18:53:46 -0500 Message-ID: --===============3922100244648576050== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: nbelaevski Date: 2009-03-03 18:53:46 -0500 (Tue, 03 Mar 2009) New Revision: 12815 Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/sarissa.js Log: https://jira.jboss.org/jira/browse/RF-1234 Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/sarissa.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/sarissa.js 2009-03-03 = 18:22:16 UTC (rev 12814) +++ trunk/framework/impl/src/main/javascript/ajaxjsf/sarissa.js 2009-03-03 = 23:53:46 UTC (rev 12815) @@ -481,7 +481,17 @@ = if((typeof(document.importNode) =3D=3D "undefined") && Sarissa._SARISSA_IS= _IE){ try{ - /** + var importTable =3D { + TBODY: ['', '
' ], + THEAD: ['', '
' ], + TFOOT: ['', '
' ], + TR: ['', '
' ], + TH: ['', '
'], + TD: ['', '
'], + OPTION: ['' ] + }; = + + /** * Implementation of importNode for the context window document in = IE. * If oNode is a TextNode, bChildren is i= gnored. * @param oNode the Node to import @@ -494,33 +504,53 @@ return document.createTextNode(oNode.data); } else { - var tbody =3D false; - if(oNode.nodeName =3D=3D "tbody" && oNode.parentNode){ - oNode =3D oNode.parentNode; - tbody =3D true; - } - else if(oNode.nodeName =3D=3D "tbody" || oNode.nodeName = =3D=3D "tr"){ - tmp =3D document.createElement("tr"); - } - else if(oNode.nodeName =3D=3D "td"){ - tmp =3D document.createElement("tr"); - } - else if(oNode.nodeName =3D=3D "option"){ - tmp =3D document.createElement("select"); - } - if(!tmp){ - tmp =3D document.createElement("div"); - } - if(bChildren){ - tmp.innerHTML =3D oNode.xml ? oNode.xml : oNode.outerH= TML; - }else{ - tmp.innerHTML =3D oNode.xml ? oNode.cloneNode(false).x= ml : oNode.cloneNode(false).outerHTML; - } - if (tbody) { - return tmp.firstChild.tBodies[0]; = + var tagName =3D oNode.nodeName.toUpperCase(); + var wrapper =3D importTable[tagName]; + = + var nodeHtml; = + if (bChildren) { + nodeHtml =3D oNode.xml ? oNode.xml : oNode.outerHTML; } else { - return tmp.getElementsByTagName("*")[0]; + nodeHtml =3D oNode.xml ? oNode.cloneNode(false).xml : = oNode.cloneNode(false).outerHTML; } + = + var wrapperElt =3D document.createElement("div"); + if (wrapper) { + nodeHtml =3D wrapper[0] + nodeHtml + wrapper[1]; + } + + wrapperElt.innerHTML =3D nodeHtml; = + + //Breadth-first search + var stack =3D new Array(wrapperElt.firstChild); + var result; + + while (!result) { + var newStack =3D new Array(); + + for (var i =3D 0; i < stack.length && !result; i++) { + var elt =3D stack[i]; + while (elt) { + if (elt.tagName /* we can meet text nodes */ && = + elt.tagName.toUpperCase() =3D=3D tagName) { + = + result =3D elt; + break; + } else { + if (elt.firstChild) { + newStack.push(elt.firstChild); + } + = + elt =3D elt.nextSibling; + } + } + } + + stack =3D newStack; = + } + //Breadth-first search end + + return result; } }; }catch(e){ } --===============3922100244648576050==--