incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r511179 - in /incubator/xap/trunk: codebase/src/xap/xml/dom/XapElement.js codebase/src/xap/xml/xmodify/CommandDirective.js unittests/testsrc/xap/xmodify/_TestxModifyHTML.html
Date Sat, 24 Feb 2007 01:09:09 GMT
Author: jmargaris
Date: Fri Feb 23 17:09:08 2007
New Revision: 511179

URL: http://svn.apache.org/viewvc?view=rev&rev=511179
Log:
unit tests now passing in all browsers

Modified:
    incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js
    incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js
    incubator/xap/trunk/unittests/testsrc/xap/xmodify/_TestxModifyHTML.html

Modified: incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js?view=diff&rev=511179&r1=511178&r2=511179
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js (original)
+++ incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js Fri Feb 23 17:09:08 2007
@@ -39,6 +39,9 @@
  
  
  //TODO exception handling in this class is all messed up
+ 
+ //TODO cloneNode is a real DOM method, we should implement
+ //that instead of deepClone()
 
 /**
  * This constructor should not be used directly.  Use xap.xml.dom.Document.createElement()


Modified: incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js?view=diff&rev=511179&r1=511178&r2=511179
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js (original)
+++ incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js Fri Feb 23 17:09:08
2007
@@ -44,9 +44,6 @@
  * @author mmikhaylov@nexaweb.com
  */
  
-//----------------------------------------------------------------------
-// Constructors.
-//----------------------------------------------------------------------
 
 /**
 *
@@ -73,15 +70,7 @@
 	this._directiveSet = directiveSet;
 	this._log = xap.xml.xmodify.CommandDirective.s_log;
 	
-}; // end Constructor(...)
-
-
-
-//-----------------------------------------------------------------------
-//
-// 		Class Fields and Methods
-//
-//-----------------------------------------------------------------------
+}; 
 
 
 /**
@@ -218,14 +207,6 @@
     return targetNodesArray;
 };
 
-
-//-----------------------------------------------------------------------
-//
-// 		Public methods. (Publc instance methods)
-//
-//-----------------------------------------------------------------------
-
-
 /**
  * Executes this command directive against the passed-in context node---
  * First find the targets of the operation on construction, then execute
@@ -786,7 +767,7 @@
         var toClone = targetNodes[n] ;
         if (toClone.nodeType == google.DOM_ELEMENT_NODE) {
         	var clone = null;
-            if(toClone instanceof google.Xnode) {
+            if(toClone instanceof google.XNode) {
             	clone = toClone.deepClone();
             } else { // assume HTML document
             	clone = this.makeHtmlNode(toClone);
@@ -853,12 +834,6 @@
 	}	
 };
 
-//-----------------------------------------------------------------------
-//
-//		Helper functions
-//
-//-----------------------------------------------------------------------
-
 /**
  * Creates target node(s) from the source element
  * 
@@ -938,9 +913,10 @@
 
 
 /*
- * Creates new HTML node out of source node.
- * @param sourceNode {Xnode} 
- * @return HTML node with the same name and attributes as sourceNode
+ * Creates new HTML node out of source node which is either an HTML node
+ * or an XNode.
+ * @param sourceNode A google XNode or HTML node. 
+ * @return An HTML node with the same name and attributes as sourceNode.
  */
 xap.xml.xmodify.CommandDirective.prototype.makeHtmlNode = function(sourceNode) {
 
@@ -952,32 +928,33 @@
 		return document.createTextNode();
 	}
 	
-
-	//create the element
-    var targetNode = document.createElement(sourceNode.nodeName);
-    
-    //copy over the attributes
-	for(var i = 0; i < sourceNode.attributes.length; i++ ) {
-	    var key = sourceNode.attributes[i].nodeName;
-	    var value = sourceNode.attributes[i].nodeValue;
-        targetNode.setAttribute(key, value);
-    }
-    
-    //clone the children
-	for(var j = 0; j < sourceNode.childNodes.length; j++ ) {
-		var childNode = sourceNode.childNodes[j];
-		if( (childNode.nodeType == google.DOM_TEXT_NODE) ) {
-			if(childNode.nodeValue) { targetNode.appendChild(document.createTextNode(childNode.nodeValue));
}
-		}else{
-		    targetNode.appendChild(this.makeHtmlNode(childNode));
+	else if (sourceNode instanceof google.XNode){
+		//create the element
+	    var targetNode = document.createElement(sourceNode.nodeName);
+	    
+	    //copy over the attributes
+		for(var i = 0; i < sourceNode.attributes.length; i++ ) {
+		    var key = sourceNode.attributes[i].nodeName;
+		    var value = sourceNode.attributes[i].nodeValue;
+	        targetNode.setAttribute(key, value);
+	    }
+	    
+	    //clone the children
+		for(var j = 0; j < sourceNode.childNodes.length; j++ ) {
+			var childNode = sourceNode.childNodes[j];
+			if( (childNode.nodeType == google.DOM_TEXT_NODE) ) {
+				if(childNode.nodeValue) { targetNode.appendChild(document.createTextNode(childNode.nodeValue));
}
+			}else{
+			    targetNode.appendChild(this.makeHtmlNode(childNode));
+			}
 		}
 	}
-    
+	else{ //source was an HTML node
+		targetNode = sourceNode.cloneNode(true);		
+	}
+	    
     //return the new html node
     return targetNode;
 };
-
-
-//End of xap.xml.xmodify.CommandDirective
 
     

Modified: incubator/xap/trunk/unittests/testsrc/xap/xmodify/_TestxModifyHTML.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/xmodify/_TestxModifyHTML.html?view=diff&rev=511179&r1=511178&r2=511179
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/xmodify/_TestxModifyHTML.html (original)
+++ incubator/xap/trunk/unittests/testsrc/xap/xmodify/_TestxModifyHTML.html Fri Feb 23 17:09:08
2007
@@ -134,7 +134,7 @@
 function testInsertAtElement(){
 	var element = document.getElementById("insertAt");
 	assertEquals("Check insert at element worked correctly", 
-					'<br>insert text<br>', element.innerHTML);						
+					'<br>insert text<br>', element.innerHTML.toLowerCase());						
 }
 
 function testReplaceChildren(){
@@ -147,7 +147,7 @@
 function testAppendWithVariable(){
 	var element = document.getElementById("appendWithVariableTarget");
 	assertEquals("Check variable worked correctly", 
-					'<br>alias<br>me', element.innerHTML);						
+					'<br>alias<br>me', element.innerHTML.toLowerCase());						
 }
 
 
@@ -155,13 +155,13 @@
 function testAppendWithClone(){
 	var element = document.getElementById("appendWithCloneTarget");
 	assertEquals("Check clone worked correctly", 
-					'clone<br>me', element.innerHTML);						
+					'clone<br>me', element.innerHTML.toLowerCase());						
 }
 
 function testSetInnerHtml(){
 	var element = document.getElementById("setInnerHtml");
 	assertEquals("Check set-innerhtml worked correctly", 
-					'text here', element.innerHTML);						
+					'text here', element.innerHTML.toLowerCase());						
 }
 
 
@@ -233,6 +233,7 @@
         		    	    <tr>
         		    	        <td valign="top">
         		    	        	<table width="100%" height="100%" id="myTable">
+        		    	        		<tbody>
 	        		    	            <tr>
 	        		    	                <th style="border-bottom: 1px solid #000000">Customer
ID</th>
 	        		    	                <th style="border-bottom: 1px solid #000000">Name</th>
@@ -288,6 +289,7 @@
 	        		    	               <td colspan="6" style="border-top:1px solid #000000">
                  		    	         
 	        		    	               </td>
 	        		    	            </tr>
+	        		    	            </tbody>
 	        		    	        </table>
         		    	        </td>
         		    	        <td width="30%" valign="top" align="right">



Mime
View raw message