aboutsummaryrefslogtreecommitdiff
path: root/node_modules/xmlbuilder/lib/XMLStringifier.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/xmlbuilder/lib/XMLStringifier.js')
-rw-r--r--node_modules/xmlbuilder/lib/XMLStringifier.js50
1 files changed, 14 insertions, 36 deletions
diff --git a/node_modules/xmlbuilder/lib/XMLStringifier.js b/node_modules/xmlbuilder/lib/XMLStringifier.js
index f54946131..c3c4722be 100644
--- a/node_modules/xmlbuilder/lib/XMLStringifier.js
+++ b/node_modules/xmlbuilder/lib/XMLStringifier.js
@@ -1,30 +1,25 @@
-// Generated by CoffeeScript 1.10.0
+// Generated by CoffeeScript 1.9.1
(function() {
- var XMLStringifier, camelCase, kebabCase, ref, snakeCase, titleCase,
+ var XMLStringifier,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
hasProp = {}.hasOwnProperty;
- ref = require('./Utility'), camelCase = ref.camelCase, titleCase = ref.titleCase, kebabCase = ref.kebabCase, snakeCase = ref.snakeCase;
-
module.exports = XMLStringifier = (function() {
function XMLStringifier(options) {
this.assertLegalChar = bind(this.assertLegalChar, this);
- var key, ref1, value;
- options || (options = {});
- this.allowSurrogateChars = options.allowSurrogateChars;
- this.noDoubleEncoding = options.noDoubleEncoding;
- this.textCase = options.textCase;
- ref1 = options.stringify || {};
- for (key in ref1) {
- if (!hasProp.call(ref1, key)) continue;
- value = ref1[key];
+ var key, ref, value;
+ this.allowSurrogateChars = options != null ? options.allowSurrogateChars : void 0;
+ this.noDoubleEncoding = options != null ? options.noDoubleEncoding : void 0;
+ ref = (options != null ? options.stringify : void 0) || {};
+ for (key in ref) {
+ if (!hasProp.call(ref, key)) continue;
+ value = ref[key];
this[key] = value;
}
}
XMLStringifier.prototype.eleName = function(val) {
val = '' + val || '';
- val = this.applyCase(val);
return this.assertLegalChar(val);
};
@@ -35,7 +30,9 @@
XMLStringifier.prototype.cdata = function(val) {
val = '' + val || '';
- val = val.replace(']]>', ']]]]><![CDATA[>');
+ if (val.match(/]]>/)) {
+ throw new Error("Invalid CDATA text: " + val);
+ }
return this.assertLegalChar(val);
};
@@ -52,8 +49,7 @@
};
XMLStringifier.prototype.attName = function(val) {
- val = '' + val || '';
- return val = this.applyCase(val);
+ return '' + val || '';
};
XMLStringifier.prototype.attValue = function(val) {
@@ -155,24 +151,6 @@
return str;
};
- XMLStringifier.prototype.applyCase = function(str) {
- switch (this.textCase) {
- case "camel":
- return camelCase(str);
- case "title":
- return titleCase(str);
- case "kebab":
- case "lower":
- return kebabCase(str);
- case "snake":
- return snakeCase(str);
- case "upper":
- return kebabCase(str).toUpperCase();
- default:
- return str;
- }
- };
-
XMLStringifier.prototype.elEscape = function(str) {
var ampregex;
ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
@@ -182,7 +160,7 @@
XMLStringifier.prototype.attEscape = function(str) {
var ampregex;
ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
- return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
+ return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
};
return XMLStringifier;