Skip to content

Commit

Permalink
fix(xml parser): Fix text node data event.
Browse files Browse the repository at this point in the history
  • Loading branch information
hdeshev committed Jun 17, 2015
1 parent 7ce98a7 commit 67cfab2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js-libs/easysax/easysax.js
Expand Up @@ -105,7 +105,7 @@ EasySAXParser.prototype.on = function(name, cb) {
case 'error': this.onError = cb || nullFunc; break;
case 'startNode': this.onStartNode = cb || nullFunc; break;
case 'endNode': this.onEndNode = cb || nullFunc; break;
case 'textNode': onTextNode = cb || nullFunc; break;
case 'textNode': this.onTextNode = cb || nullFunc; break;
case 'cdata': this.onCDATA = cb || nullFunc; break;

case 'comment': this.onComment = cb; this.is_onComment = !!cb; break;
Expand Down
9 changes: 9 additions & 0 deletions node-tests/test-xml.ts
Expand Up @@ -4,6 +4,7 @@ import xml = require('xml');
describe("xml parser", () => {
let last_element = null;
let last_attrs = null;
let last_data = null;
let parser = null;

beforeEach(() => {
Expand All @@ -13,6 +14,9 @@ describe("xml parser", () => {
last_element = event.elementName;
last_attrs = event.attributes;
break;
case xml.ParserEventType.Text:
last_data = event.data;
break;
}
});
});
Expand All @@ -26,4 +30,9 @@ describe("xml parser", () => {
assert.equal('TextField', last_element);
assert.equal('hello', last_attrs['text']);
});

it("resolves entities", () => {
parser.parse("<element>&lt;&gt;&quot;&amp;&apos;</element>");
assert.equal("<>\"&'", last_data);
});
});

0 comments on commit 67cfab2

Please sign in to comment.