Author: nbelaevski
Date: 2008-05-01 16:14:23 -0400 (Thu, 01 May 2008)
New Revision: 8395
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
Log:
http://jira.jboss.com/jira/browse/RF-3318
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-05-01 18:54:45 UTC
(rev 8394)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-05-01 20:14:23 UTC
(rev 8395)
@@ -296,7 +296,9 @@
var _this = this;
window.setTimeout(function() {
for (var i = 0; i < newscripts.length; i++){
- var newscript = Sarissa.getText( newscripts[i],true ) ; // TODO - Mozilla
disable innerHTML in XML page ..."";
+ var includeComments = !A4J.AJAX.isXhtmlScriptMode();
+ var newscript = A4J.AJAX.getText(newscripts[i], includeComments) ; // TODO -
Mozilla disable innerHTML in XML page ..."";
+
try {
LOG.debug("Evaluate script replaced area in document: ",
newscript);
if (window.execScript) {
@@ -1410,3 +1412,58 @@
} catch(e){ /* Mozilla in XHTML mode not have innerHTML */ };
},0);
}
+
+A4J.AJAX.getText = function(oNode, includeComment) {
+ var s = "";
+ var nodes = oNode.childNodes;
+ for(var i=0; i < nodes.length; i++){
+ var node = nodes[i];
+ var nodeType = node.nodeType;
+
+ if(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE ||
+ (includeComment && nodeType == Node.COMMENT_NODE)){
+
+ s += node.data;
+ } else if(nodeType == Node.ELEMENT_NODE || nodeType == Node.DOCUMENT_NODE ||
nodeType == Node.DOCUMENT_FRAGMENT_NODE){
+ s += arguments.callee(node, includeComment);
+ }
+ }
+ return s;
+}
+
+A4J.AJAX.isXhtmlScriptMode = function() {
+ if (!this._xhtmlScriptMode) {
+ var elt = document.createElement("div");
+ elt.innerHTML = "<script
type='text/javascript'><!--\r\n/**/\r\n//--></script>";
+
+ var commentFound = false;
+ var s = elt.firstChild;
+
+ while (s) {
+ if (s.nodeType == Node.ELEMENT_NODE) {
+ var c = s.firstChild;
+
+ while (c) {
+ if (c.nodeType == Node.COMMENT_NODE) {
+ commentFound = true;
+ break;
+ }
+
+ c = c.nextSibling;
+ }
+
+ break;
+ }
+
+ s = s.nextSibling;
+ }
+
+ if (commentFound) {
+ this._xhtmlScriptMode = 2;
+ } else {
+ this._xhtmlScriptMode = 1;
+ }
+ }
+
+ return this._xhtmlScriptMode > 1;
+}