Socket
Socket
Sign inDemoInstall

sax

Package Overview
Dependencies
0
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.3 to 0.5.0

test/cyrillic.js

50

examples/example.js
var fs = require("fs"),
util = require('util'),
util = require("util"),
path = require("path"),
xml = fs.cat(path.join(__dirname, "test.xml")),
xml = fs.readFileSync(path.join(__dirname, "test.xml"), "utf8"),
sax = require("../lib/sax"),

@@ -10,33 +10,21 @@ strict = sax.parser(true),

inspector = function (ev) { return function (data) {
// util.error("");
// util.error(ev+": "+util.inspect(data));
// for (var i in data) util.error(i+ " "+util.inspect(data[i]));
// util.error(this.line+":"+this.column);
console.error("%s %s %j", this.line+":"+this.column, ev, data);
}};
xml.addCallback(function (xml) {
// strict.write(xml);
sax.EVENTS.forEach(function (ev) {
loose["on"+ev] = inspector(ev);
});
loose.onend = function () {
// util.error("end");
// util.error(util.inspect(loose));
};
// do this one char at a time to verify that it works.
// (function () {
// if (xml) {
// loose.write(xml.substr(0,1000));
// xml = xml.substr(1000);
// process.nextTick(arguments.callee);
// } else loose.close();
// })();
for (var i = 0; i < 1000; i ++) {
loose.write(xml);
loose.close();
}
sax.EVENTS.forEach(function (ev) {
loose["on"+ev] = inspector(ev);
});
loose.onend = function () {
console.error("end");
console.error(loose);
};
});
// 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));
xml = xml.substr(c);
process.nextTick(arguments.callee);
} else loose.close();
})();

@@ -54,3 +54,3 @@ // wrapper for non-node envs

parser.opt = opt || {}
parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags;
parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase"

@@ -237,4 +237,2 @@ parser.tags = []

// (Letter | "_" | ":")
, nameStart = letter+"_:"
, nameBody = nameStart+number+"-."
, quote = "'\""

@@ -253,4 +251,13 @@ , entity = number+letter+"#"

letter = charClass(letter)
nameStart = charClass(nameStart)
nameBody = charClass(nameBody)
// http://www.w3.org/TR/REC-xml/#NT-NameStartChar
// This implementation works on strings, a single character at a time
// as such, it cannot ever support astral-plane characters (10000-EFFFF)
// without a significant breaking change to either this parser, or the
// JavaScript language. Implementation of an emoji-capable xml parser
// is left as an exercise for the reader.
var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/
quote = charClass(quote)

@@ -267,8 +274,12 @@ entity = charClass(entity)

function isRegExp (c) {
return Object.prototype.toString.call(c) === '[object RegExp]'
}
function is (charclass, c) {
return charclass[c]
return isRegExp(charclass) ? !!c.match(charclass) : charclass[c]
}
function not (charclass, c) {
return !charclass[c]
return !is(charclass, c)
}

@@ -297,3 +308,2 @@

, PROC_INST_BODY : S++ // <?hi there
, PROC_INST_QUOTED : S++ // <?hi "there
, PROC_INST_ENDING : S++ // <?hi "there" ?

@@ -317,9 +327,263 @@ , OPEN_TAG : S++ // <strong

sax.ENTITIES =
{ "apos" : "'"
{ "amp" : "&"
, "gt" : ">"
, "lt" : "<"
, "quot" : "\""
, "amp" : "&"
, "gt" : ">"
, "lt" : "<"
, "apos" : "'"
, "AElig" : 198
, "Aacute" : 193
, "Acirc" : 194
, "Agrave" : 192
, "Aring" : 197
, "Atilde" : 195
, "Auml" : 196
, "Ccedil" : 199
, "ETH" : 208
, "Eacute" : 201
, "Ecirc" : 202
, "Egrave" : 200
, "Euml" : 203
, "Iacute" : 205
, "Icirc" : 206
, "Igrave" : 204
, "Iuml" : 207
, "Ntilde" : 209
, "Oacute" : 211
, "Ocirc" : 212
, "Ograve" : 210
, "Oslash" : 216
, "Otilde" : 213
, "Ouml" : 214
, "THORN" : 222
, "Uacute" : 218
, "Ucirc" : 219
, "Ugrave" : 217
, "Uuml" : 220
, "Yacute" : 221
, "aacute" : 225
, "acirc" : 226
, "aelig" : 230
, "agrave" : 224
, "aring" : 229
, "atilde" : 227
, "auml" : 228
, "ccedil" : 231
, "eacute" : 233
, "ecirc" : 234
, "egrave" : 232
, "eth" : 240
, "euml" : 235
, "iacute" : 237
, "icirc" : 238
, "igrave" : 236
, "iuml" : 239
, "ntilde" : 241
, "oacute" : 243
, "ocirc" : 244
, "ograve" : 242
, "oslash" : 248
, "otilde" : 245
, "ouml" : 246
, "szlig" : 223
, "thorn" : 254
, "uacute" : 250
, "ucirc" : 251
, "ugrave" : 249
, "uuml" : 252
, "yacute" : 253
, "yuml" : 255
, "copy" : 169
, "reg" : 174
, "nbsp" : 160
, "iexcl" : 161
, "cent" : 162
, "pound" : 163
, "curren" : 164
, "yen" : 165
, "brvbar" : 166
, "sect" : 167
, "uml" : 168
, "ordf" : 170
, "laquo" : 171
, "not" : 172
, "shy" : 173
, "macr" : 175
, "deg" : 176
, "plusmn" : 177
, "sup1" : 185
, "sup2" : 178
, "sup3" : 179
, "acute" : 180
, "micro" : 181
, "para" : 182
, "middot" : 183
, "cedil" : 184
, "ordm" : 186
, "raquo" : 187
, "frac14" : 188
, "frac12" : 189
, "frac34" : 190
, "iquest" : 191
, "times" : 215
, "divide" : 247
, "OElig" : 338
, "oelig" : 339
, "Scaron" : 352
, "scaron" : 353
, "Yuml" : 376
, "fnof" : 402
, "circ" : 710
, "tilde" : 732
, "Alpha" : 913
, "Beta" : 914
, "Gamma" : 915
, "Delta" : 916
, "Epsilon" : 917
, "Zeta" : 918
, "Eta" : 919
, "Theta" : 920
, "Iota" : 921
, "Kappa" : 922
, "Lambda" : 923
, "Mu" : 924
, "Nu" : 925
, "Xi" : 926
, "Omicron" : 927
, "Pi" : 928
, "Rho" : 929
, "Sigma" : 931
, "Tau" : 932
, "Upsilon" : 933
, "Phi" : 934
, "Chi" : 935
, "Psi" : 936
, "Omega" : 937
, "alpha" : 945
, "beta" : 946
, "gamma" : 947
, "delta" : 948
, "epsilon" : 949
, "zeta" : 950
, "eta" : 951
, "theta" : 952
, "iota" : 953
, "kappa" : 954
, "lambda" : 955
, "mu" : 956
, "nu" : 957
, "xi" : 958
, "omicron" : 959
, "pi" : 960
, "rho" : 961
, "sigmaf" : 962
, "sigma" : 963
, "tau" : 964
, "upsilon" : 965
, "phi" : 966
, "chi" : 967
, "psi" : 968
, "omega" : 969
, "thetasym" : 977
, "upsih" : 978
, "piv" : 982
, "ensp" : 8194
, "emsp" : 8195
, "thinsp" : 8201
, "zwnj" : 8204
, "zwj" : 8205
, "lrm" : 8206
, "rlm" : 8207
, "ndash" : 8211
, "mdash" : 8212
, "lsquo" : 8216
, "rsquo" : 8217
, "sbquo" : 8218
, "ldquo" : 8220
, "rdquo" : 8221
, "bdquo" : 8222
, "dagger" : 8224
, "Dagger" : 8225
, "bull" : 8226
, "hellip" : 8230
, "permil" : 8240
, "prime" : 8242
, "Prime" : 8243
, "lsaquo" : 8249
, "rsaquo" : 8250
, "oline" : 8254
, "frasl" : 8260
, "euro" : 8364
, "image" : 8465
, "weierp" : 8472
, "real" : 8476
, "trade" : 8482
, "alefsym" : 8501
, "larr" : 8592
, "uarr" : 8593
, "rarr" : 8594
, "darr" : 8595
, "harr" : 8596
, "crarr" : 8629
, "lArr" : 8656
, "uArr" : 8657
, "rArr" : 8658
, "dArr" : 8659
, "hArr" : 8660
, "forall" : 8704
, "part" : 8706
, "exist" : 8707
, "empty" : 8709
, "nabla" : 8711
, "isin" : 8712
, "notin" : 8713
, "ni" : 8715
, "prod" : 8719
, "sum" : 8721
, "minus" : 8722
, "lowast" : 8727
, "radic" : 8730
, "prop" : 8733
, "infin" : 8734
, "ang" : 8736
, "and" : 8743
, "or" : 8744
, "cap" : 8745
, "cup" : 8746
, "int" : 8747
, "there4" : 8756
, "sim" : 8764
, "cong" : 8773
, "asymp" : 8776
, "ne" : 8800
, "equiv" : 8801
, "le" : 8804
, "ge" : 8805
, "sub" : 8834
, "sup" : 8835
, "nsub" : 8836
, "sube" : 8838
, "supe" : 8839
, "oplus" : 8853
, "otimes" : 8855
, "perp" : 8869
, "sdot" : 8901
, "lceil" : 8968
, "rceil" : 8969
, "lfloor" : 8970
, "rfloor" : 8971
, "lang" : 9001
, "rang" : 9002
, "loz" : 9674
, "spades" : 9824
, "clubs" : 9827
, "hearts" : 9829
, "diams" : 9830
}
Object.keys(sax.ENTITIES).forEach(function (key) {
var e = sax.ENTITIES[key]
var s = typeof e === 'number' ? String.fromCharCode(e) : e
sax.ENTITIES[key] = s
})
for (var S in sax.STATE) sax.STATE[sax.STATE[S]] = S

@@ -365,2 +629,3 @@

function end (parser) {
if (!parser.closedRoot) strictFail(parser, "Unclosed root tag")
if (parser.state !== S.TEXT) error(parser, "Unexpected end")

@@ -406,2 +671,8 @@ closeText(parser)

if (!parser.strict) parser.attribName = parser.attribName[parser.looseCase]()
if (parser.attribList.hasOwnProperty(parser.attribName) ||
parser.tag.attributes.hasOwnProperty(parser.attribName)) {
return parser.attribName = parser.attribValue = ""
}
if (parser.opt.xmlns) {

@@ -504,2 +775,4 @@ var qn = qname(parser.attribName)

parser.tag.isSelfClosing = !!selfClosing
// process the tag

@@ -530,2 +803,14 @@ parser.sawRoot = true

}
if (parser.script) {
if (parser.tagName !== "script") {
parser.script += "</" + parser.tagName + ">"
parser.tagName = ""
parser.state = S.SCRIPT
return
}
emitNode(parser, "onscript", parser.script)
parser.script = ""
}
// first make sure that the closing tag actually exists.

@@ -578,6 +863,11 @@ // <a><b></c></b></a> will close everything, otherwise.

function parseEntity (parser) {
var entity = parser.entity.toLowerCase()
var entity = parser.entity
, entityLC = entity.toLowerCase()
, num
, numStr = ""
if (parser.ENTITIES[entity]) return parser.ENTITIES[entity]
if (parser.ENTITIES[entity])
return parser.ENTITIES[entity]
if (parser.ENTITIES[entityLC])
return parser.ENTITIES[entityLC]
entity = entityLC
if (entity.charAt(0) === "#") {

@@ -620,4 +910,6 @@ if (entity.charAt(1) === "x") {

case S.BEGIN:
if (c === "<") parser.state = S.OPEN_WAKA
else if (not(whitespace,c)) {
if (c === "<") {
parser.state = S.OPEN_WAKA
parser.startTagPosition = parser.position
} else if (not(whitespace,c)) {
// have to process this as a text node.

@@ -646,4 +938,6 @@ // weird, but happens.

}
if (c === "<") parser.state = S.OPEN_WAKA
else {
if (c === "<") {
parser.state = S.OPEN_WAKA
parser.startTagPosition = parser.position
} else {
if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot))

@@ -665,6 +959,3 @@ strictFail("Text data outside of root node.")

if (c === "/") {
emitNode(parser, "onscript", parser.script)
parser.state = S.CLOSE_TAG
parser.script = ""
parser.tagName = ""
} else {

@@ -684,7 +975,5 @@ parser.script += "<" + c

} else if (is(nameStart,c)) {
parser.startTagPosition = parser.position - 1
parser.state = S.OPEN_TAG
parser.tagName = c
} else if (c === "/") {
parser.startTagPosition = parser.position - 1
parser.state = S.CLOSE_TAG

@@ -697,2 +986,7 @@ parser.tagName = ""

strictFail(parser, "Unencoded <")
// if there was some whitespace, then add that in.
if (parser.startTagPosition + 1 < parser.position) {
var pad = parser.position - parser.startTagPosition
c = new Array(pad).join(" ") + c
}
parser.textNode += "<" + c

@@ -840,7 +1134,3 @@ parser.state = S.TEXT

else if (c === "?") parser.state = S.PROC_INST_ENDING
else if (is(quote, c)) {
parser.state = S.PROC_INST_QUOTED
parser.q = c
parser.procInstBody += c
} else parser.procInstBody += c
else parser.procInstBody += c
continue

@@ -862,10 +1152,2 @@

case S.PROC_INST_QUOTED:
parser.procInstBody += c
if (c === parser.q) {
parser.state = S.PROC_INST_BODY
parser.q = ""
}
continue
case S.OPEN_TAG:

@@ -909,2 +1191,8 @@ if (is(nameBody, c)) parser.tagName += c

if (c === "=") parser.state = S.ATTRIB_VALUE
else if (c === ">") {
strictFail(parser, "Attribute without value")
parser.attribValue = parser.attribName
attrib(parser)
openTag(parser)
}
else if (is(whitespace, c)) parser.state = S.ATTRIB_NAME_SAW_WHITE

@@ -973,9 +1261,18 @@ else if (is(nameBody, c)) parser.attribName += c

if (is(whitespace, c)) continue
else if (not(nameStart, c)) strictFail(parser,
"Invalid tagname in closing tag.")
else parser.tagName = c
else if (not(nameStart, c)) {
if (parser.script) {
parser.script += "</" + c
parser.state = S.SCRIPT
} else {
strictFail(parser, "Invalid tagname in closing tag.")
}
} else parser.tagName = c
}
else if (c === ">") closeTag(parser)
else if (is(nameBody, c)) parser.tagName += c
else {
else if (parser.script) {
parser.script += "</" + parser.tagName
parser.tagName = ""
parser.state = S.SCRIPT
} else {
if (not(whitespace, c)) strictFail(parser,

@@ -982,0 +1279,0 @@ "Invalid tagname in closing tag")

@@ -5,3 +5,3 @@ {

"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
"version": "0.4.3",
"version": "0.5.0",
"main": "lib/sax.js",

@@ -8,0 +8,0 @@ "license": {

@@ -84,3 +84,3 @@ # sax js

.pipe(saxStream)
.pipe(fs.createReadStream("file-copy.xml"))
.pipe(fs.createWriteStream("file-copy.xml"))

@@ -87,0 +87,0 @@

@@ -13,3 +13,4 @@ // set this really low so that I don't have to put 64 MB of xml in here.

"name": "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ",
"attributes": {}
"attributes": {},
"isSelfClosing": false
}],

@@ -16,0 +17,0 @@ ["text", "yo"],

@@ -9,3 +9,4 @@ // default to uppercase

, [ "opentag", { name: "SPAN",
attributes: { CLASS: "test", HELLO: "world" } } ]
attributes: { CLASS: "test", HELLO: "world" },
isSelfClosing: false } ]
, [ "closetag", "SPAN" ]

@@ -26,3 +27,4 @@ ]

, [ "opentag", { name: "span",
attributes: { class: "test", hello: "world" } } ]
attributes: { class: "test", hello: "world" },
isSelfClosing: false } ]
, [ "closetag", "span" ]

@@ -43,3 +45,4 @@ ]

, [ "opentag", { name: "span",
attributes: { class: "test", hello: "world" } } ]
attributes: { class: "test", hello: "world" },
isSelfClosing: false } ]
, [ "closetag", "span" ]

@@ -46,0 +49,0 @@ ]

require(__dirname).test({
expect : [
["opentag", {"name": "R","attributes": {}}],
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
["opencdata", undefined],

@@ -6,0 +6,0 @@ ["cdata", " this is character data  "],

require(__dirname).test({
expect : [
["opentag", {"name": "R","attributes": {}}],
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
["opencdata", undefined],

@@ -6,0 +6,0 @@ ["cdata", " this is "],

var p = require(__dirname).test({
expect : [
["opentag", {"name": "R","attributes": {}}],
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
["opencdata", undefined],

@@ -20,3 +20,3 @@ ["cdata", "[[[[[[[[]]]]]]]]"],

expect : [
["opentag", {"name": "R","attributes": {}}],
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
["opencdata", undefined],

@@ -23,0 +23,0 @@ ["cdata", "[[[[[[[[]]]]]]]]"],

require(__dirname).test({
expect : [
["opentag", {"name": "R","attributes": {}}],
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
["opencdata", undefined],

@@ -6,0 +6,0 @@ ["cdata", " this is "],

require(__dirname).test({
xml : "<r><![CDATA[ this is character data  ]]></r>",
expect : [
["opentag", {"name": "R","attributes": {}}],
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
["opencdata", undefined],

@@ -6,0 +6,0 @@ ["cdata", " this is character data  "],

@@ -16,20 +16,20 @@

, expect :
[ [ "opentag", { name: "COMPILECLASSESRESPONSE", attributes: {} } ]
, [ "opentag", { name : "RESULT", attributes: {} } ]
, [ "opentag", { name: "BODYCRC", attributes: {} } ]
[ [ "opentag", { name: "COMPILECLASSESRESPONSE", attributes: {}, isSelfClosing: false } ]
, [ "opentag", { name : "RESULT", attributes: {}, isSelfClosing: false } ]
, [ "opentag", { name: "BODYCRC", attributes: {}, isSelfClosing: false } ]
, [ "text", "653724009" ]
, [ "closetag", "BODYCRC" ]
, [ "opentag", { name: "COLUMN", attributes: {} } ]
, [ "opentag", { name: "COLUMN", attributes: {}, isSelfClosing: false } ]
, [ "text", "-1" ]
, [ "closetag", "COLUMN" ]
, [ "opentag", { name: "ID", attributes: {} } ]
, [ "opentag", { name: "ID", attributes: {}, isSelfClosing: false } ]
, [ "text", "01pG0000002KoSUIA0" ]
, [ "closetag", "ID" ]
, [ "opentag", {name: "LINE", attributes: {} } ]
, [ "opentag", {name: "LINE", attributes: {}, isSelfClosing: false } ]
, [ "text", "-1" ]
, [ "closetag", "LINE" ]
, [ "opentag", {name: "NAME", attributes: {} } ]
, [ "opentag", {name: "NAME", attributes: {}, isSelfClosing: false } ]
, [ "text", "CalendarController" ]
, [ "closetag", "NAME" ]
, [ "opentag", {name: "SUCCESS", attributes: {} } ]
, [ "opentag", {name: "SUCCESS", attributes: {}, isSelfClosing: false } ]
, [ "text", "true" ]

@@ -36,0 +36,0 @@ , [ "closetag", "SUCCESS" ]

@@ -11,7 +11,7 @@ // https://github.com/isaacs/sax-js/issues/33

, expect :
[ [ "opentag", { name: "xml", attributes: {} } ]
[ [ "opentag", { name: "xml", attributes: {}, isSelfClosing: false } ]
, [ "text", "\n" ]
, [ "comment", " \n comment with a single dash- in it\n" ]
, [ "text", "\n" ]
, [ "opentag", { name: "data", attributes: {} } ]
, [ "opentag", { name: "data", attributes: {}, isSelfClosing: true } ]
, [ "closetag", "data" ]

@@ -18,0 +18,0 @@ , [ "text", "\n" ]

@@ -7,3 +7,3 @@ // https://github.com/isaacs/sax-js/issues/35

, expect :
[ [ "opentag", { name: "xml", attributes: {} } ]
[ [ "opentag", { name: "xml", attributes: {}, isSelfClosing: false } ]
, [ "text", "\r\r\n" ]

@@ -10,0 +10,0 @@ , [ "closetag", "xml" ]

// https://github.com/isaacs/sax-js/issues/47
require(__dirname).test
( { xml : '<a href="query.svc?x=1&y=2&z=3"/>'
, expect : [
, expect : [
[ "attribute", { name:'href', value:"query.svc?x=1&y=2&z=3"} ],
[ "opentag", { name: "a", attributes: { href:"query.svc?x=1&y=2&z=3"} } ],
[ "opentag", { name: "a", attributes: { href:"query.svc?x=1&y=2&z=3"}, isSelfClosing: true } ],
[ "closetag", "a" ]

@@ -8,0 +8,0 @@ ]

@@ -5,4 +5,4 @@ // https://github.com/isaacs/sax-js/issues/49

, expect :
[ [ "opentag", { name: "xml", attributes: {} } ]
, [ "opentag", { name: "script", attributes: {} } ]
[ [ "opentag", { name: "xml", attributes: {}, isSelfClosing: false } ]
, [ "opentag", { name: "script", attributes: {}, isSelfClosing: false } ]
, [ "text", "hello world" ]

@@ -20,4 +20,4 @@ , [ "closetag", "script" ]

, expect :
[ [ "opentag", { name: "xml", attributes: {} } ]
, [ "opentag", { name: "script", attributes: {} } ]
[ [ "opentag", { name: "xml", attributes: {}, isSelfClosing: false } ]
, [ "opentag", { name: "script", attributes: {}, isSelfClosing: false } ]
, [ "opencdata", undefined ]

@@ -24,0 +24,0 @@ , [ "cdata", "hello world" ]

require(__dirname).test({
xml : "<html><head><script>if (1 < 0) { console.log('elo there'); }</script></head></html>",
expect : [
["opentag", {"name": "HTML","attributes": {}}],
["opentag", {"name": "HEAD","attributes": {}}],
["opentag", {"name": "SCRIPT","attributes": {}}],
["opentag", {"name": "HTML","attributes": {}, "isSelfClosing": false}],
["opentag", {"name": "HEAD","attributes": {}, "isSelfClosing": false}],
["opentag", {"name": "SCRIPT","attributes": {}, "isSelfClosing": false}],
["script", "if (1 < 0) { console.log('elo there'); }"],

@@ -8,0 +8,0 @@ ["closetag", "SCRIPT"],

@@ -15,11 +15,14 @@

"name": "root",
"attributes": {}
"attributes": {},
"isSelfClosing": false
}],
["opentag", {
"name": "child",
"attributes": {}
"attributes": {},
"isSelfClosing": false
}],
["opentag", {
"name": "haha",
"attributes": {}
"attributes": {},
"isSelfClosing": true
}],

@@ -30,3 +33,4 @@ ["closetag", "haha"],

"name": "monkey",
"attributes": {}
"attributes": {},
"isSelfClosing": false
}],

@@ -33,0 +37,0 @@ ["text", "=(|)"],

@@ -15,11 +15,14 @@

"name": "ROOT",
"attributes": {}
"attributes": {},
"isSelfClosing": false
}],
["opentag", {
"name": "CHILD",
"attributes": {}
"attributes": {},
"isSelfClosing": false
}],
["opentag", {
"name": "HAHA",
"attributes": {}
"attributes": {},
"isSelfClosing": true
}],

@@ -30,3 +33,4 @@ ["closetag", "HAHA"],

"name": "MONKEY",
"attributes": {}
"attributes": {},
"isSelfClosing": false
}],

@@ -33,0 +37,0 @@ ["text", "=(|)"],

@@ -12,10 +12,10 @@

expect : [
["opentag", {name:"ROOT", attributes:{}}],
["opentag", {name:"HAHA", attributes:{}}],
["opentag", {name:"ROOT", attributes:{}, isSelfClosing: false}],
["opentag", {name:"HAHA", attributes:{}, isSelfClosing: true}],
["closetag", "HAHA"],
["opentag", {name:"HAHA", attributes:{}}],
["opentag", {name:"HAHA", attributes:{}, isSelfClosing: true}],
["closetag", "HAHA"],
// ["opentag", {name:"HAHA", attributes:{}}],
// ["closetag", "HAHA"],
["opentag", {name:"MONKEY", attributes:{}}],
["opentag", {name:"MONKEY", attributes:{}, isSelfClosing: false}],
["text", "=(|)"],

@@ -22,0 +22,0 @@ ["closetag", "MONKEY"],

@@ -7,4 +7,4 @@ // stray ending tags should just be ignored in non-strict mode.

, expect :
[ [ "opentag", { name: "A", attributes: {} } ]
, [ "opentag", { name: "B", attributes: {} } ]
[ [ "opentag", { name: "A", attributes: {}, isSelfClosing: false } ]
, [ "opentag", { name: "B", attributes: {}, isSelfClosing: false } ]
, [ "text", "</c>" ]

@@ -11,0 +11,0 @@ , [ "closetag", "B" ]

@@ -7,3 +7,4 @@

"name": "SPAN",
"attributes": {}
"attributes": {},
isSelfClosing: false
}],

@@ -10,0 +11,0 @@ ["text", "Welcome,"],

@@ -10,3 +10,4 @@ // unquoted attributes should be ok in non-strict mode

, [ "opentag", { name: "SPAN",
attributes: { CLASS: "test", HELLO: "world" } } ]
attributes: { CLASS: "test", HELLO: "world" },
isSelfClosing: false } ]
, [ "closetag", "SPAN" ]

@@ -13,0 +14,0 @@ ]

@@ -51,2 +51,3 @@ var t = require(__dirname)

, ns: {"a": "http://ATTRIBUTE"}
, isSelfClosing: true
}

@@ -53,0 +54,0 @@ ]

@@ -23,3 +23,4 @@

, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
ns: { x: 'x1', y: 'y1' } } ]
ns: { x: 'x1', y: 'y1' },
isSelfClosing: false } ]

@@ -30,3 +31,4 @@ , [ "opennamespace", { prefix: "x", uri: "x2" } ]

attributes: { "xmlns:x": { name: "xmlns:x", value: "x2", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } },
ns: { x: 'x2' } } ]
ns: { x: 'x2' },
isSelfClosing: false } ]

@@ -38,3 +40,4 @@ , [ "attribute", { name: "x:a", value: "x2", uri: "x2", prefix: "x", local: "a" } ]

, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
ns: { x: 'x2' } } ]
ns: { x: 'x2' },
isSelfClosing: true } ]

@@ -51,3 +54,4 @@ , [ "closetag", "check" ]

, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
ns: { x: 'x1', y: 'y1' } } ]
ns: { x: 'x1', y: 'y1' },
isSelfClosing: true } ]
, [ "closetag", "check" ]

@@ -54,0 +58,0 @@

@@ -17,3 +17,3 @@

[ [ "opentag", { name: "root", prefix: "", local: "root", uri: "",
attributes: {}, ns: {} } ]
attributes: {}, ns: {}, isSelfClosing: false } ]

@@ -23,3 +23,3 @@ , [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]

attributes: { "attr": { name: "attr", value: "normal", uri: "", prefix: "", local: "attr", uri: "" } },
ns: {} } ]
ns: {}, isSelfClosing: true } ]
, [ "closetag", "plain" ]

@@ -32,7 +32,8 @@

attributes: { "xmlns": { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } },
ns: { "": "uri:default" } } ]
ns: { "": "uri:default" }, isSelfClosing: false } ]
, [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]
, [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "uri:default", ns: { '': 'uri:default' },
attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } } } ]
attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } },
isSelfClosing: true } ]
, [ "closetag", "plain" ]

@@ -50,3 +51,3 @@

attributes: { "xmlns:a": { name: "xmlns:a", value: "uri:nsa", prefix: "xmlns", local: "a", uri: "http://www.w3.org/2000/xmlns/" } },
ns: { a: "uri:nsa" } } ]
ns: { a: "uri:nsa" }, isSelfClosing: false } ]

@@ -56,3 +57,4 @@ , [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]

attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } },
ns: { a: 'uri:nsa' } } ]
ns: { a: 'uri:nsa' },
isSelfClosing: true } ]
, [ "closetag", "plain" ]

@@ -63,3 +65,4 @@

attributes: { "a:attr": { name: "a:attr", value: "namespaced", prefix: "a", local: "attr", uri: "uri:nsa" } },
ns: { a: 'uri:nsa' } } ]
ns: { a: 'uri:nsa' },
isSelfClosing: true } ]
, [ "closetag", "a:ns" ]

@@ -66,0 +69,0 @@

@@ -11,3 +11,3 @@

attributes: { "unbound:attr": { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } },
ns: {} } ]
ns: {}, isSelfClosing: true } ]
, [ "closetag", "root" ]

@@ -14,0 +14,0 @@ ]

@@ -23,3 +23,4 @@ var xmlns_attr =

ns : { "" : "http://foo" },
attributes: { xmlns: xmlns_attr, attr: attr_attr } } ]
attributes: { xmlns: xmlns_attr, attr: attr_attr },
isSelfClosing: true } ]
, [ "closetag", "elm" ]

@@ -26,0 +27,0 @@ , [ "closenamespace", { prefix: "", uri: "http://foo"} ]

@@ -27,2 +27,3 @@ require(__dirname).test(

, ns: {}
, isSelfClosing: true
}

@@ -29,0 +30,0 @@ ]

@@ -12,2 +12,3 @@ require(__dirname).test(

, ns: {}
, isSelfClosing: true
}

@@ -14,0 +15,0 @@ ]

@@ -32,2 +32,3 @@ require(__dirname).test(

, ns: {}
, isSelfClosing: true
}

@@ -34,0 +35,0 @@ ]

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc