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 +13 -0
- package/package.json +1 -1
- package/test/flush.js +13 -0
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
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();
|