Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed eternal loop with error emitter

  • Loading branch information...
commit 77adfa09fe814fd45a8949969d16a7146c3c29de 1 parent 860a504
Andris Reinman authored
View
2  lib/xml2object.js
@@ -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;
View
17 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();
+};
View
1  test/fixture/input02.xml
@@ -0,0 +1 @@
+just some invalid xml data
Please sign in to comment.
Something went wrong with that request. Please try again.