Skip to content

Commit

Permalink
fix: emit empty comment
Browse files Browse the repository at this point in the history
  • Loading branch information
lddubeau committed Jul 10, 2018
1 parent 95d192f commit b3db392
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/saxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,9 +930,7 @@ class SaxesParser {
const c = this.getChar(chunkState);
if (c === "-") {
this.state = S_COMMENT_ENDED;
if (this.comment) {
this.emitNode("oncomment", this.comment);
}
this.emitNode("oncomment", this.comment);
this.comment = "";
}
else {
Expand Down
13 changes: 13 additions & 0 deletions test/comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";

require(".").test({
name: "comment",
xml: "<r><!--foo--><!----></r>",
expect: [
["opentagstart", { name: "r", attributes: {} }],
["opentag", { name: "r", attributes: {}, isSelfClosing: false }],
["comment", "foo"],
["comment", ""],
["closetag", "r"],
],
});

0 comments on commit b3db392

Please sign in to comment.