Skip to content

Commit

Permalink
Fixed eternal loop with error emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
Andris Reinman committed Jul 29, 2012
1 parent 860a504 commit 77adfa0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/xml2object.js
Expand Up @@ -140,7 +140,7 @@ var xml2object = module.exports = function(elements, source) {

// Rebroadcast the error and keep going
this.saxStream.on("error", function (e) {
this.emit('error', e);
self.emit('error', e);

// clear the error and resume
this._parser.error = null;
Expand Down
17 changes: 17 additions & 0 deletions test/error-test.js
@@ -0,0 +1,17 @@
var nodeunit = require('nodeunit');
var path = require('path');
var xml2object = require('../lib/xml2object');

exports.testError = function(test){
test.expect(1);

var parser = new xml2object(['dog'], path.normalize(__dirname + '/fixture/input02.xml'));
var found = [];

parser.on('error', function(error) {
test.ok(error instanceof Error);
test.done();
});

parser.start();
};
1 change: 1 addition & 0 deletions test/fixture/input02.xml
@@ -0,0 +1 @@
just some invalid xml data

0 comments on commit 77adfa0

Please sign in to comment.