Skip to content

Commit 67cfab2

Browse files
committed
fix(xml parser): Fix text node data event.
1 parent 7ce98a7 commit 67cfab2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

js-libs/easysax/easysax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ EasySAXParser.prototype.on = function(name, cb) {
105105
case 'error': this.onError = cb || nullFunc; break;
106106
case 'startNode': this.onStartNode = cb || nullFunc; break;
107107
case 'endNode': this.onEndNode = cb || nullFunc; break;
108-
case 'textNode': onTextNode = cb || nullFunc; break;
108+
case 'textNode': this.onTextNode = cb || nullFunc; break;
109109
case 'cdata': this.onCDATA = cb || nullFunc; break;
110110

111111
case 'comment': this.onComment = cb; this.is_onComment = !!cb; break;

node-tests/test-xml.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import xml = require('xml');
44
describe("xml parser", () => {
55
let last_element = null;
66
let last_attrs = null;
7+
let last_data = null;
78
let parser = null;
89

910
beforeEach(() => {
@@ -13,6 +14,9 @@ describe("xml parser", () => {
1314
last_element = event.elementName;
1415
last_attrs = event.attributes;
1516
break;
17+
case xml.ParserEventType.Text:
18+
last_data = event.data;
19+
break;
1620
}
1721
});
1822
});
@@ -26,4 +30,9 @@ describe("xml parser", () => {
2630
assert.equal('TextField', last_element);
2731
assert.equal('hello', last_attrs['text']);
2832
});
33+
34+
it("resolves entities", () => {
35+
parser.parse("<element>&lt;&gt;&quot;&amp;&apos;</element>");
36+
assert.equal("<>\"&'", last_data);
37+
});
2938
});

0 commit comments

Comments
 (0)