Comparing version 0.4.0 to 0.5.0
@@ -5,3 +5,3 @@ (function () { | ||
if (typeof module !== 'undefined' && module.exports) { | ||
if (typeof module !== 'undefined' && module.exports && !GLOBAL.xmldocAssumeBrowser) { | ||
// We're being used in a Node-like environment | ||
@@ -28,5 +28,6 @@ sax = require('sax'); | ||
this.name = tag.name; | ||
this.attr = tag.attributes || {}; | ||
this.attr = tag.attributes; | ||
this.val = ""; | ||
this.isValCdata = false; | ||
this.isValComment = false; | ||
this.children = []; | ||
@@ -64,12 +65,15 @@ this.firstChild = null; | ||
XmlElement.prototype._text = function(text) { | ||
if (text) this.val += text; | ||
this.val += text; | ||
}; | ||
XmlElement.prototype._cdata = function(cdata) { | ||
if (cdata) { | ||
this.val += cdata; | ||
this.isValCdata=true; | ||
} | ||
this.val += cdata; | ||
this.isValCdata=true; | ||
}; | ||
XmlElement.prototype._comment = function(comment) { | ||
this.val += comment; | ||
this.isValComment=true; | ||
} | ||
XmlElement.prototype._error = function(err) { | ||
@@ -232,2 +236,3 @@ throw err; | ||
parser.oncdata = parser_cdata; | ||
parser.oncomment = parser_comment; | ||
parser.onerror = parser_error; | ||
@@ -237,7 +242,8 @@ } | ||
// create these closures and cache them by keeping them file-scoped | ||
function parser_opentag() { delegates[0]._opentag.apply(delegates[0],arguments) } | ||
function parser_closetag() { delegates[0]._closetag.apply(delegates[0],arguments) } | ||
function parser_text() { delegates[0]._text.apply(delegates[0],arguments) } | ||
function parser_cdata() { delegates[0]._cdata.apply(delegates[0],arguments) } | ||
function parser_error() { delegates[0]._error.apply(delegates[0],arguments) } | ||
function parser_opentag() { delegates[0] && delegates[0]._opentag.apply(delegates[0],arguments) } | ||
function parser_closetag() { delegates[0] && delegates[0]._closetag.apply(delegates[0],arguments) } | ||
function parser_text() { delegates[0] && delegates[0]._text.apply(delegates[0],arguments) } | ||
function parser_cdata() { delegates[0] && delegates[0]._cdata.apply(delegates[0],arguments) } | ||
function parser_comment() { delegates[0] && delegates[0]._comment.apply(delegates[0],arguments) } | ||
function parser_error() { delegates[0] && delegates[0]._error.apply(delegates[0],arguments) } | ||
@@ -253,7 +259,7 @@ // a relatively standard extend method | ||
function escapeXML(value){ | ||
return value.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, '&').replace(/'/g, ''').replace(/"/g, '"'); | ||
return value.replace(/&/g, '&').replace(/</g, "<").replace(/>/g, ">").replace(/'/g, ''').replace(/"/g, '"'); | ||
} | ||
// Are we being used in a Node-like environment? | ||
if (typeof module !== 'undefined' && module.exports) | ||
if (typeof module !== 'undefined' && module.exports && !GLOBAL.xmldocAssumeBrowser) | ||
module.exports.XmlDocument = XmlDocument; | ||
@@ -260,0 +266,0 @@ else |
@@ -9,4 +9,8 @@ { | ||
}, | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"main": "./index", | ||
"scripts": { | ||
"test": "tap test/*.js", | ||
"coverage": "npm test -- --cov --coverage-report=html" | ||
}, | ||
"dependencies": { | ||
@@ -29,3 +33,6 @@ "sax": "~1.1.1" | ||
], | ||
"readmeFilename": "README.md" | ||
"readmeFilename": "README.md", | ||
"devDependencies": { | ||
"tap": "^5.7.1" | ||
} | ||
} |
[![Build Status](https://travis-ci.org/nfarina/xmldoc.svg)](https://travis-ci.org/nfarina/xmldoc) | ||
[![Coverage Status](https://coveralls.io/repos/github/nfarina/xmldoc/badge.svg?branch=master)](https://coveralls.io/github/nfarina/xmldoc?branch=master) | ||
## Introduction | ||
@@ -3,0 +6,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25890
12
434
142
1