NPM Dependencies UPDATE
This commit is contained in:
1 parent
d3bc5e34f6
commit
5bfb4ff32a
732 files changed
+13367
-62155
No files matched your search
+10
-50
@@ -133,24 +133,11 @@ function clearBuffers (parser) {
|
||||
}
|
||||
}
|
||||
|
||||
function flushBuffers (parser) {
|
||||
closeText(parser)
|
||||
if (parser.cdata !== "") {
|
||||
emitNode(parser, "oncdata", parser.cdata)
|
||||
parser.cdata = ""
|
||||
}
|
||||
if (parser.script !== "") {
|
||||
emitNode(parser, "onscript", parser.script)
|
||||
parser.script = ""
|
||||
}
|
||||
}
|
||||
|
||||
SAXParser.prototype =
|
||||
{ end: function () { end(this) }
|
||||
, write: write
|
||||
, resume: function () { this.error = null; return this }
|
||||
, close: function () { return this.write(null) }
|
||||
, flush: function () { flushBuffers(this) }
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -192,8 +179,6 @@ function SAXStream (strict, opt) {
|
||||
me._parser.error = null
|
||||
}
|
||||
|
||||
this._decoder = null;
|
||||
|
||||
streamWraps.forEach(function (ev) {
|
||||
Object.defineProperty(me, "on" + ev, {
|
||||
get: function () { return me._parser["on" + ev] },
|
||||
@@ -214,23 +199,13 @@ SAXStream.prototype = Object.create(Stream.prototype,
|
||||
{ constructor: { value: SAXStream } })
|
||||
|
||||
SAXStream.prototype.write = function (data) {
|
||||
if (typeof Buffer === 'function' &&
|
||||
typeof Buffer.isBuffer === 'function' &&
|
||||
Buffer.isBuffer(data)) {
|
||||
if (!this._decoder) {
|
||||
var SD = require('string_decoder').StringDecoder
|
||||
this._decoder = new SD('utf8')
|
||||
}
|
||||
data = this._decoder.write(data);
|
||||
}
|
||||
|
||||
this._parser.write(data.toString())
|
||||
this.emit("data", data)
|
||||
return true
|
||||
}
|
||||
|
||||
SAXStream.prototype.end = function (chunk) {
|
||||
if (chunk && chunk.length) this.write(chunk)
|
||||
if (chunk && chunk.length) this._parser.write(chunk.toString())
|
||||
this._parser.end()
|
||||
return true
|
||||
}
|
||||
@@ -334,7 +309,6 @@ sax.STATE =
|
||||
, ATTRIB_NAME_SAW_WHITE : S++ // <a foo _
|
||||
, ATTRIB_VALUE : S++ // <a foo=
|
||||
, ATTRIB_VALUE_QUOTED : S++ // <a foo="bar
|
||||
, ATTRIB_VALUE_CLOSED : S++ // <a foo="bar"
|
||||
, ATTRIB_VALUE_UNQUOTED : S++ // <a foo=bar
|
||||
, ATTRIB_VALUE_ENTITY_Q : S++ // <foo bar="""
|
||||
, ATTRIB_VALUE_ENTITY_U : S++ // <foo bar="
|
||||
@@ -647,7 +621,7 @@ function error (parser, er) {
|
||||
|
||||
function end (parser) {
|
||||
if (!parser.closedRoot) strictFail(parser, "Unclosed root tag")
|
||||
if ((parser.state !== S.BEGIN) && (parser.state !== S.TEXT)) error(parser, "Unexpected end")
|
||||
if (parser.state !== S.TEXT) error(parser, "Unexpected end")
|
||||
closeText(parser)
|
||||
parser.c = ""
|
||||
parser.closed = true
|
||||
@@ -672,14 +646,14 @@ function newTag (parser) {
|
||||
parser.attribList.length = 0
|
||||
}
|
||||
|
||||
function qname (name, attribute) {
|
||||
function qname (name) {
|
||||
var i = name.indexOf(":")
|
||||
, qualName = i < 0 ? [ "", name ] : name.split(":")
|
||||
, prefix = qualName[0]
|
||||
, local = qualName[1]
|
||||
|
||||
// <x "xmlns"="http://foo">
|
||||
if (attribute && name === "xmlns") {
|
||||
if (name === "xmlns") {
|
||||
prefix = "xmlns"
|
||||
local = ""
|
||||
}
|
||||
@@ -690,13 +664,13 @@ function qname (name, attribute) {
|
||||
function attrib (parser) {
|
||||
if (!parser.strict) parser.attribName = parser.attribName[parser.looseCase]()
|
||||
|
||||
if (parser.attribList.indexOf(parser.attribName) !== -1 ||
|
||||
if (parser.attribList.hasOwnProperty(parser.attribName) ||
|
||||
parser.tag.attributes.hasOwnProperty(parser.attribName)) {
|
||||
return parser.attribName = parser.attribValue = ""
|
||||
return parser.attribName = parser.attribValue = ""
|
||||
}
|
||||
|
||||
if (parser.opt.xmlns) {
|
||||
var qn = qname(parser.attribName, true)
|
||||
var qn = qname(parser.attribName)
|
||||
, prefix = qn.prefix
|
||||
, local = qn.local
|
||||
|
||||
@@ -745,12 +719,11 @@ function openTag (parser, selfClosing) {
|
||||
var qn = qname(parser.tagName)
|
||||
tag.prefix = qn.prefix
|
||||
tag.local = qn.local
|
||||
tag.uri = tag.ns[qn.prefix] || ""
|
||||
tag.uri = tag.ns[qn.prefix] || qn.prefix
|
||||
|
||||
if (tag.prefix && !tag.uri) {
|
||||
strictFail(parser, "Unbound namespace prefix: "
|
||||
+ JSON.stringify(parser.tagName))
|
||||
tag.uri = qn.prefix
|
||||
}
|
||||
|
||||
var parent = parser.tags[parser.tags.length - 1] || parser
|
||||
@@ -769,7 +742,7 @@ function openTag (parser, selfClosing) {
|
||||
var nv = parser.attribList[i]
|
||||
var name = nv[0]
|
||||
, value = nv[1]
|
||||
, qualName = qname(name, true)
|
||||
, qualName = qname(name)
|
||||
, prefix = qualName.prefix
|
||||
, local = qualName.local
|
||||
, uri = prefix == "" ? "" : (tag.ns[prefix] || "")
|
||||
@@ -1251,20 +1224,7 @@ function write (chunk) {
|
||||
}
|
||||
attrib(parser)
|
||||
parser.q = ""
|
||||
parser.state = S.ATTRIB_VALUE_CLOSED
|
||||
continue
|
||||
|
||||
case S.ATTRIB_VALUE_CLOSED:
|
||||
if (is(whitespace, c)) {
|
||||
parser.state = S.ATTRIB
|
||||
} else if (c === ">") openTag(parser)
|
||||
else if (c === "/") parser.state = S.OPEN_TAG_SLASH
|
||||
else if (is(nameStart, c)) {
|
||||
strictFail(parser, "No whitespace between attributes")
|
||||
parser.attribName = c
|
||||
parser.attribValue = ""
|
||||
parser.state = S.ATTRIB_NAME
|
||||
} else strictFail(parser, "Invalid attribute name")
|
||||
parser.state = S.ATTRIB
|
||||
continue
|
||||
|
||||
case S.ATTRIB_VALUE_UNQUOTED:
|
||||
|
||||
Reference in new issue
Block a user