You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by an...@apache.org on 2006/11/20 15:11:41 UTC
svn commit: r477182 - in
/tapestry/tapestry4/trunk/tapestry-framework/src/js: tapestry/html.js
tests/test_html.js
Author: andyhot
Date: Mon Nov 20 06:11:41 2006
New Revision: 477182
URL: http://svn.apache.org/viewvc?view=rev&rev=477182
Log:
TAPESTRY-1129: Document and test tapestry.html package... in anticipation for changes :)
Added:
tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/html.js
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/html.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/html.js?view=diff&rev=477182&r1=477181&r2=477182
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/html.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/html.js Mon Nov 20 06:11:41 2006
@@ -1,7 +1,28 @@
dojo.provide("tapestry.html");
+/**
+ * package: tapestry.html
+ * Provides functionality related to parsing and rendering dom nodes.
+ *
+ * TODO: Mark all functions (apart from getContentAsString) as 'private'.
+ */
tapestry.html={
+ /**
+ * Function: getContentAsString
+ *
+ * Takes a dom node and returns its contents rendered in a string.
+ *
+ * The resulting string does NOT contain any markup (or attributes) of
+ * the given node - only child nodes are rendered and returned.
+ *
+ * Parameters:
+ *
+ * node - The dom node.
+ * Returns:
+ *
+ * A string with the html content of the given node.
+ */
getContentAsString:function(node){
if (typeof node.xml != "undefined")
return this.getContentAsStringIE(node);
@@ -10,7 +31,7 @@
else
return this.getContentAsStringGeneric(node);
},
-
+
getContentAsStringIE:function(node){
var s="";
for (var i = 0; i < node.childNodes.length; i++)
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js?view=auto&rev=477182
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js Mon Nov 20 06:11:41 2006
@@ -0,0 +1,21 @@
+dojo.registerModulePath("tapestry", "../tapestry");
+
+dojo.require("tapestry.core");
+dojo.require("tapestry.test");
+dojo.require("tapestry.html");
+
+
+function test_html_getContentAsString(){
+ var node = document.createElement("div");
+ node.setAttribute("id", "testid");
+
+ var node2 = document.createElement("div");
+ node2.setAttribute("id", "testid2");
+ var content = document.createTextNode("content");
+ node2.appendChild(content);
+
+ node.appendChild(node2);
+
+ var data = tapestry.html.getContentAsString(node).toLowerCase();
+ jum.assertEquals("<div id=\"testid2\">content</div>", data);
+}