fix(xml parser): Fix text node data event.

This commit is contained in:
Hristo Deshev
2015-06-05 17:25:48 +03:00
parent 7ce98a75e4
commit 67cfab233a
2 changed files with 10 additions and 1 deletions

View File

@ -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;

View File

@ -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(() => {
@ -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;
}
});
});
@ -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);
});
});