Hi,

I think Jayfresh and I spotted a regression in jquery implemention of
createTiddlyText:
function createTiddlyText(parent,text)
{
        return jQuery(parent).append(text);
}
returns the parent instead of the created element.
Althought is given "<div>" as text argument it will create html
<div></div> instead of a text node with '<div>' as content.

This as the side effect of breaking TiddlyTemplating stuff:
when using a template:
<div><!--<<viewer text>>--></div>
expands to:
<div></div>text
instead of:
<div>text</div>

Would you consider reverting to the previous implementation ?
function createTiddlyText(theParent,theText)
{
        return theParent.appendChild(document.createTextNode(theText));
}

#jquery guys told me that jquery provide no good way to manipulate text
node directly.

I attached a patch, that add a test to the qunit test suite to reproduce
the issue, and revert to the createTiddlyText previous implementation.
-- 
Johan Euphrosine <pro...@aminche.com>
Index: test/js/DOM.js
===================================================================
--- test/js/DOM.js	(revision 9965)
+++ test/js/DOM.js	(working copy)
@@ -30,6 +30,15 @@
 		ok(jQuery('div.testClass'), 'Setting the element class parameter should set the class on the DOM element');
 
 	});
+
+	test("createTiddlyText", function() {
+		expect(1);
+		var parent = makeTestNode();
+		createTiddlyText(parent, "<div>");
+		createTiddlyText(parent, "a");
+		createTiddlyText(parent, "</div>");
+		equals(parent.innerHTML, "&lt;div&gt;a&lt;/div&gt;", "createTiddlyText should append text node, not html element");
+	});
 	
 
 	test("addClass", function() {
Index: js/Dom.js
===================================================================
--- js/Dom.js	(revision 9965)
+++ js/Dom.js	(working copy)
@@ -310,7 +310,7 @@
 
 function createTiddlyText(parent,text)
 {
-	return jQuery(parent).append(text);
+	return parent.appendChild(document.createTextNode(text));
 }
 
 // Return the content of an element as plain text with no formatting

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to