W3C home > Mailing lists > Public > public-dap-commits@w3.org > September 2011

2009/dap/ReSpec.js/js respec.js,1.168,1.169

From: Robin Berjon via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 21 Sep 2011 10:27:57 +0000
To: public-dap-commits@w3.org
Message-Id: <E1R6K21-00019M-Bm@lionel-hutz.w3.org>
Update of /sources/public/2009/dap/ReSpec.js/js
In directory hutz:/tmp/cvs-serv4402/js

Modified Files:
	respec.js 
Log Message:
debug for toXML

Index: respec.js
===================================================================
RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -d -r1.168 -r1.169
--- respec.js	21 Sep 2011 09:57:45 -0000	1.168
+++ respec.js	21 Sep 2011 10:27:55 -0000	1.169
@@ -334,6 +334,7 @@
     },
 
     toXML:        function () {
+        console.log("toXML");
         var str = "<?xml version='1.0' encoding='UTF-8'?>\n<!DOCTYPE html";
         var dt = document.doctype;
         if (dt && dt.publicId) {
@@ -376,28 +377,26 @@
             }
         }
         str += ">\n";
+        console.log("start document", str);
         // walk the entire DOM tree grabbing nodes and emitting them - possibly modifying them
         // if they need the funny closing tag
         var pRef = this ;
         var selfClosing = {};
         "br img input area base basefont col isindex link meta param hr".split(" ").forEach(function (n) {
             selfClosing[n] = true;
-        })
+        });
+        console.log("selfClosing", selfClosing);
         var dumpNode = function (node) {
             var out = '' ;
             // if the node is the document node.. process the children
             if ( node.nodeType == 9 || ( node.nodeType == 1 && node.nodeName.toLowerCase() == 'html' ) ) {
-                var children = node.childNodes;
-                var cLen = children.length ;
-                if (cLen) {
-                    for (var i = 0; i < cLen; i++) {
-                        out += dumpNode(children[i]) ;
-                    }
-                }
+                console.log("processing children of document or root element");
+                for (var i = 0; i < node.childNodes.length; i++) out += dumpNode(node.childNodes[i]) ;
             } 
             // element
             else if (1 === node.nodeType) {
                 var ename = node.nodeName.toLowerCase() ;
+                console.log("processing element", ename);
                 out += '<' + ename ;
                 for (var i = 0; i < node.attributes.length; i++) {
                     var atn = node.attributes[i]
@@ -420,14 +419,17 @@
             }
             // comments
             else if (8 === node.nodeType) {
+                console.log("processing comment");
                 out += "\n<!-- " + node.nodeValue + " -->\n";
             }
             // text or cdata
             else if (3 === node.nodeType || 4 === node.nodeType) {
+                console.log("processing text");
                 out += this._esc(node.nodeValue);
             }
             // we don't handle other types for the time being
             else {
+                console.log("unknown type", node.nodeType);
                 warning("Cannot handle serialising nodes of type: " + node.nodeType);
             }
             return out;
@@ -435,6 +437,7 @@
         var node = document.documentElement;
         str += dumpNode(document.documentElement) ;
         str += "</html>";
+        console.log("DONE");
         return str;
     },
     
Received on Wednesday, 21 September 2011 10:27:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 21 September 2011 10:27:59 GMT