Socket
Socket
Sign inDemoInstall

xmlbuilder

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xmlbuilder - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

6

lib/XMLBuilder.js

@@ -27,5 +27,2 @@ (function() {

}
if ((doctype != null) && !(doctype.name != null)) {
throw new Error("Document name is required");
}
if (xmldec != null) {

@@ -53,5 +50,4 @@ xmldec.version = '' + xmldec.version || '';

if (doctype != null) {
doctype.name = '' + doctype.name || '';
att = {
name: doctype.name
name: name
};

@@ -58,0 +54,0 @@ if (doctype.ext != null) {

107

lib/XMLFragment.js

@@ -45,2 +45,79 @@ (function() {

};
XMLFragment.prototype.insertBefore = function(name, attributes, text) {
var child, i, key, val, _ref, _ref2;
if (!(name != null)) {
throw new Error("Missing element name");
}
name = '' + name || '';
this.assertLegalChar(name);
if (attributes != null) {
attributes;
} else {
attributes = {};
};
if (this.is(attributes, 'String') && this.is(text, 'Object')) {
_ref = [text, attributes], attributes = _ref[0], text = _ref[1];
} else if (this.is(attributes, 'String')) {
_ref2 = [{}, attributes], attributes = _ref2[0], text = _ref2[1];
}
for (key in attributes) {
if (!__hasProp.call(attributes, key)) continue;
val = attributes[key];
val = '' + val || '';
attributes[key] = this.escape(val);
}
child = new XMLFragment(this.parent, name, attributes);
if (text != null) {
text = '' + text || '';
text = this.escape(text);
this.assertLegalChar(text);
child.text(text);
}
i = this.parent.children.indexOf(this);
this.parent.children.splice(i, 0, child);
return child;
};
XMLFragment.prototype.insertAfter = function(name, attributes, text) {
var child, i, key, val, _ref, _ref2;
if (!(name != null)) {
throw new Error("Missing element name");
}
name = '' + name || '';
this.assertLegalChar(name);
if (attributes != null) {
attributes;
} else {
attributes = {};
};
if (this.is(attributes, 'String') && this.is(text, 'Object')) {
_ref = [text, attributes], attributes = _ref[0], text = _ref[1];
} else if (this.is(attributes, 'String')) {
_ref2 = [{}, attributes], attributes = _ref2[0], text = _ref2[1];
}
for (key in attributes) {
if (!__hasProp.call(attributes, key)) continue;
val = attributes[key];
val = '' + val || '';
attributes[key] = this.escape(val);
}
child = new XMLFragment(this.parent, name, attributes);
if (text != null) {
text = '' + text || '';
text = this.escape(text);
this.assertLegalChar(text);
child.text(text);
}
i = this.parent.children.indexOf(this);
this.parent.children.splice(i + 1, 0, child);
return child;
};
XMLFragment.prototype.remove = function() {
var i, _ref;
if (!(this.parent != null)) {
throw new Error("Cannot remove the root element");
}
i = this.parent.children.indexOf(this);
[].splice.apply(this.parent.children, [i, i - i + 1].concat(_ref = [])), _ref;
return this.parent;
};
XMLFragment.prototype.text = function(value) {

@@ -103,2 +180,24 @@ var child;

};
XMLFragment.prototype.prev = function() {
var i;
if (!(this.parent != null)) {
throw new Error("This node has no parent");
}
i = this.parent.children.indexOf(this);
if (i < 1) {
throw new Error("Already at the first node");
}
return this.parent.children[i - 1];
};
XMLFragment.prototype.next = function() {
var i;
if (!(this.parent != null)) {
throw new Error("This node has no parent");
}
i = this.parent.children.indexOf(this);
if (i === -1 || i === this.parent.children.length - 1) {
throw new Error("Already at the last node");
}
return this.parent.children[i + 1];
};
XMLFragment.prototype.attribute = function(name, value) {

@@ -122,2 +221,10 @@ var _ref;

};
XMLFragment.prototype.removeAttribute = function(name) {
if (!(name != null)) {
throw new Error("Missing attribute name");
}
name = '' + name || '';
delete this.attributes[name];
return this;
};
XMLFragment.prototype.toString = function(options, level) {

@@ -124,0 +231,0 @@ var attName, attValue, child, indent, newline, pretty, r, space, _i, _len, _ref, _ref2;

{
"name" : "xmlbuilder",
"version": "0.1.7",
"name": "xmlbuilder",
"version": "0.1.8",
"keywords": "xml xmlbuilder",
"homepage": "http://github.com/oozcitak/xmlbuilder-js",
"description": "An XML builder for node.js",

@@ -27,4 +29,10 @@ "author": "Ozgur Ozcitak <oozcitak@gmail.com>",

"node": ">=0.2.0"
},
"devDependencies": {
"coffee-script": "1.1.x"
},
"scripts": {
"test": "make test"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc