[Pkg-javascript-commits] [ltx] 18/80: Imported Upstream version 0.0.5

Jonas Smedegaard dr at jones.dk
Sun Feb 28 10:50:08 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository ltx.

commit 4c783834e01d0370beee515835f673c87c1e556a
Author: dr at jones.dk <dr at jones.dk>
Date:   Sat Apr 30 07:49:55 2011 +0200

    Imported Upstream version 0.0.5
---
 lib/element.js       | 8 +++++---
 package.json         | 2 +-
 test/test_element.js | 8 ++++++++
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/lib/element.js b/lib/element.js
index 8e0e981..8d0441b 100644
--- a/lib/element.js
+++ b/lib/element.js
@@ -194,10 +194,12 @@ Element.prototype.write = function(writer) {
     } else {
         writer(">");
         this.children.forEach(function(child) {
-            if (typeof child == 'string')
-                writer(escapeXml(child));
-            else
+            if (child.write)
                 child.write(writer);
+            else if (typeof child === 'string')
+                writer(escapeXml(child));
+	    else
+                writer(escapeXml(child.toString()));
         });
         writer("</");
         writer(this.name);
diff --git a/package.json b/package.json
index f6d477d..5b26440 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
 { "name": "ltx"
-,"version": "0.0.4"
+,"version": "0.0.5"
 ,"main": "./lib/index"
 ,"description": "<xml for=\"node.js\">"
 ,"author": "Stephan Maka"
diff --git a/test/test_element.js b/test/test_element.js
index 27bed1a..17de103 100644
--- a/test/test_element.js
+++ b/test/test_element.js
@@ -25,6 +25,14 @@ vows.describe('ltx').addBatch({
 	'serialize an element with text to entities': function() {
 	    var e = new ltx.Element('e').t('1 < 2').root();
 	    assert.equal(e.toString(), '<e>1 < 2</e>');
+	},
+	'serialize an element with a number attribute': function() {
+	    var e = new ltx.Element('e', { a: 23 });
+	    assert.equal(e.toString(), '<e a="23"/>');
+	},
+	'serialize an element with number contents': function() {
+	    var e = new ltx.Element('e').t(23);
+	    assert.equal(e.toString(), '<e>23</e>');
 	}
     },
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git



More information about the Pkg-javascript-commits mailing list