Skip to content
Browse files

close #8

  • Loading branch information...
1 parent 448262f commit 4d5b1290ec71db3742177966de4b4c179e44e9f4 @touv touv committed
Showing with 11 additions and 1 deletion.
  1. +6 −1 lib/xml-writer.js
  2. +5 −0 test/comments.js
View
7 lib/xml-writer.js
@@ -239,9 +239,14 @@ XMLWriter.prototype = {
return this;
} else if (this.attributes && !this.attribute) {
this.endAttributes();
+ }
+ if (this.comment) {
+ this.write(content);
+ }
+ else {
+ this.write(content.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'));
}
++this.texts;
- this.write(content.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'));
this.started_write = true;
return this;
},
View
5 test/comments.js
@@ -55,3 +55,8 @@ exports['t06'] = function (test) {
test.equal(this.xw.toString(), '<!--value-->');
test.done();
};
+exports['t06'] = function (test) {
+ this.xw.writeComment('<test>');
+ test.equal(this.xw.toString(), '<!--<test>-->');
+ test.done();
+};

0 comments on commit 4d5b129

Please sign in to comment.
Something went wrong with that request. Please try again.