Skip to content

Commit f4b56f2

Browse files
committed
Pass errors through
1 parent bfb8f68 commit f4b56f2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ module.exports = function() {
2929
delete parent.parent;
3030
parent = p;
3131
},
32+
onerror: function(err) {
33+
parser.emit('error', err);
34+
},
3235
onend: function() {
3336
parser.emit('data', parent);
3437
}

test/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,14 @@ test('should parse nested tags and text nodes', function(t) {
3232

3333
test('should parse comments', function(t) {
3434
verify('05-comments', t);
35+
});
36+
37+
test('should report errors', function(t) {
38+
var stream = jsonmlify();
39+
stream.on('error', function(err) {
40+
t.ok(err);
41+
t.end();
42+
});
43+
stream.end();
44+
stream.write('<div></div>'); // Write after close to provoke an error
3545
});

0 commit comments

Comments
 (0)