[Pkg-javascript-commits] [ltx] 212/469: handle parsing buffers w/ easysax & saxjs
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 13:03:05 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository ltx.
commit 3a497b261bdbd3e99ced7767263da3584a56e728
Author: Astro <astro at spaceboyz.net>
Date: Mon Mar 19 18:11:35 2012 +0100
handle parsing buffers w/ easysax & saxjs
---
lib/sax_easysax.js | 2 ++
lib/sax_saxjs.js | 2 ++
test/parse-test.js | 8 +++++++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/sax_easysax.js b/lib/sax_easysax.js
index d2aeec3..b28cc16 100644
--- a/lib/sax_easysax.js
+++ b/lib/sax_easysax.js
@@ -26,6 +26,8 @@ var SaxEasysax = module.exports = function SaxEasysax() {
util.inherits(SaxEasysax, events.EventEmitter);
SaxEasysax.prototype.write = function(data) {
+ if (typeof data !== 'string')
+ data = data.toString();
this.parser.parse(data);
};
diff --git a/lib/sax_saxjs.js b/lib/sax_saxjs.js
index e24cc09..1a27b6e 100644
--- a/lib/sax_saxjs.js
+++ b/lib/sax_saxjs.js
@@ -27,6 +27,8 @@ var SaxSaxjs = module.exports = function SaxSaxjs() {
util.inherits(SaxSaxjs, events.EventEmitter);
SaxSaxjs.prototype.write = function(data) {
+ if (typeof data !== 'string')
+ data = data.toString();
this.parser.write(data);
};
diff --git a/test/parse-test.js b/test/parse-test.js
index 302ebb8..e06f3e6 100644
--- a/test/parse-test.js
+++ b/test/parse-test.js
@@ -42,7 +42,13 @@ ltx.availableSaxParsers.forEach(function(saxParser) {
assert.equal(el.name, 'x:root');
assert.equal(el.getName(), 'root');
assert.ok(el.is('root', 'https://github.com/astro/ltx'));
- }
+ },
+ 'buffer': function() {
+ var buf = new Buffer('<root/>');
+ var el = parse(buf);
+ assert.equal(el.name, 'root');
+ assert.equal(0, el.children.length);
+ }
}
}).export(module);
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git
More information about the Pkg-javascript-commits
mailing list