diff --git a/lib/saxes.js b/lib/saxes.js
index 1de18573..4eb6dd22 100644
--- a/lib/saxes.js
+++ b/lib/saxes.js
@@ -986,9 +986,7 @@ class SaxesParser {
sCDataEnding2(chunkState) {
const c = this.getChar(chunkState);
if (c === ">") {
- if (this.cdata) {
- this.emitNode("oncdata", this.cdata);
- }
+ this.emitNode("oncdata", this.cdata);
this.cdata = "";
this.state = S_TEXT;
}
diff --git a/test/cdata.js b/test/cdata.js
index 34acaa83..8e16a91e 100644
--- a/test/cdata.js
+++ b/test/cdata.js
@@ -2,11 +2,12 @@
require(".").test({
name: "cdata",
- xml: "",
+ xml: "",
expect: [
["opentagstart", { name: "r", attributes: {} }],
["opentag", { name: "r", attributes: {}, isSelfClosing: false }],
["cdata", " this is character data "],
+ ["cdata", ""],
["closetag", "r"],
],
});