sax 1.4.3 → 1.4.4

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.
Files changed (2) hide show
  1. package/lib/sax.js +11 -4
  2. package/package.json +4 -1
package/lib/sax.js CHANGED
@@ -263,10 +263,9 @@
263
263
  Buffer.isBuffer(data)
264
264
  ) {
265
265
  if (!this._decoder) {
266
- var SD = require('string_decoder').StringDecoder
267
- this._decoder = new SD('utf8')
266
+ this._decoder = new TextDecoder('utf8')
268
267
  }
269
- data = this._decoder.write(data)
268
+ data = this._decoder.decode(data, { stream: true })
270
269
  }
271
270
 
272
271
  this._parser.write(data.toString())
@@ -278,6 +277,14 @@
278
277
  if (chunk && chunk.length) {
279
278
  this.write(chunk)
280
279
  }
280
+ // Flush any remaining decoded data from the TextDecoder
281
+ if (this._decoder) {
282
+ var remaining = this._decoder.decode()
283
+ if (remaining) {
284
+ this._parser.write(remaining)
285
+ this.emit('data', remaining)
286
+ }
287
+ }
281
288
  this._parser.end()
282
289
  return true
283
290
  }
@@ -1554,7 +1561,7 @@
1554
1561
  } else if (isMatch(nameBody, c)) {
1555
1562
  parser.tagName += c
1556
1563
  } else if (parser.script) {
1557
- parser.script += '</' + parser.tagName
1564
+ parser.script += '</' + parser.tagName + c
1558
1565
  parser.tagName = ''
1559
1566
  parser.state = S.SCRIPT
1560
1567
  } else {
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": "1.4.3",
5
+ "version": "1.4.4",
6
6
  "main": "lib/sax.js",
7
7
  "license": "BlueOak-1.0.0",
8
8
  "scripts": {
@@ -24,5 +24,8 @@
24
24
  },
25
25
  "tap": {
26
26
  "allow-incomplete-coverage": true
27
+ },
28
+ "engines": {
29
+ "node": ">=11.0.0"
27
30
  }
28
31
  }