sax 0.5.7 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/sax.js CHANGED
@@ -133,11 +133,24 @@ function clearBuffers (parser) {
133
133
  }
134
134
  }
135
135
 
136
+ function flushBuffers (parser) {
137
+ closeText(parser)
138
+ if (parser.cdata !== "") {
139
+ emitNode(parser, "oncdata", parser.cdata)
140
+ parser.cdata = ""
141
+ }
142
+ if (parser.script !== "") {
143
+ emitNode(parser, "onscript", parser.script)
144
+ parser.script = ""
145
+ }
146
+ }
147
+
136
148
  SAXParser.prototype =
137
149
  { end: function () { end(this) }
138
150
  , write: write
139
151
  , resume: function () { this.error = null; return this }
140
152
  , close: function () { return this.write(null) }
153
+ , flush: function () { flushBuffers(this) }
141
154
  }
142
155
 
143
156
  try {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "sax",
3
3
  "description": "An evented streaming XML parser in JavaScript",
4
4
  "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
5
- "version": "0.5.7",
5
+ "version": "0.5.8",
6
6
  "main": "lib/sax.js",
7
7
  "license": "BSD",
8
8
  "scripts": {
package/test/flush.js ADDED
@@ -0,0 +1,13 @@
1
+ var parser = require(__dirname).test({
2
+ expect: [
3
+ ['opentag', {'name':'T', attributes:{}, isSelfClosing: false}],
4
+ ['text', 'flush'],
5
+ ['text', 'rest'],
6
+ ['closetag', 'T'],
7
+ ]
8
+ });
9
+
10
+ parser.write('<T>flush');
11
+ parser.flush();
12
+ parser.write('rest</T>');
13
+ parser.close();