Skip to content

Commit

Permalink
fix: always run in strict mode
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

The API no longer takes a ``strict`` argument anywhere. This also
effectively removes support for HTML processing, or allow processing
without errors anything which is less than full XML. It also removes
special processing of ``script`` elements.
  • Loading branch information
lddubeau committed Jun 30, 2018
1 parent 813db06 commit ed8b0b1
Show file tree
Hide file tree
Showing 51 changed files with 207 additions and 639 deletions.
26 changes: 14 additions & 12 deletions examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@ var fs = require('fs'),
util = require('util'),
path = require('path'),
xml = fs.readFileSync(path.join(__dirname, 'test.xml'), 'utf8'),
sax = require('../lib/sax'),
strict = sax.parser(true),
loose = sax.parser(false, {trim: true}),
saxes = require('../lib/saxes'),
parser = saxes.parser(),
inspector = function (ev) { return function (data) {
console.error('%s %s %j', this.line + ':' + this.column, ev, data)
}}
console.error('%s %s %j', this.line + ':' + this.column, ev, data)
if (ev === "error") {
parser.resume()
}
}}

sax.EVENTS.forEach(function (ev) {
loose['on' + ev] = inspector(ev)
saxes.EVENTS.forEach(function (ev) {
parser['on' + ev] = inspector(ev)
})
loose.onend = function () {
parser.onend = function () {
console.error('end')
console.error(loose)
console.error(parser)
}

// do this in random bits at a time to verify that it works.
(function () {
if (xml) {
var c = Math.ceil(Math.random() * 1000)
loose.write(xml.substr(0, c))
parser.write(xml.substr(0, c))
xml = xml.substr(c)
process.nextTick(arguments.callee)
} else loose.close()
})()
} else parser.close()
}())
Loading

0 comments on commit ed8b0b1

Please sign in to comment.