xmlbuilder
Advanced tools
Comparing version 0.3.1 to 0.3.2
(function() { | ||
var XMLBuilder, XMLFragment; | ||
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { | ||
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } | ||
function ctor() { this.constructor = child; } | ||
ctor.prototype = parent.prototype; | ||
child.prototype = new ctor; | ||
child.__super__ = parent.prototype; | ||
return child; | ||
}; | ||
XMLFragment = require('./XMLFragment'); | ||
XMLBuilder = (function() { | ||
function XMLBuilder() { | ||
XMLBuilder.__super__.constructor.call(this, null, '', {}, ''); | ||
this.isDoc = true; | ||
this.children = []; | ||
this.rootObject = null; | ||
} | ||
__extends(XMLBuilder, XMLFragment); | ||
XMLBuilder.prototype.begin = function(name, xmldec, doctype, options) { | ||
XMLBuilder.prototype.begin = function(name, xmldec, doctype) { | ||
var att, child, root; | ||
@@ -62,5 +53,10 @@ if (!(name != null)) { | ||
root.isRoot = true; | ||
root.documentObject = this; | ||
this.children.push(root); | ||
this.rootObject = root; | ||
return root; | ||
}; | ||
XMLBuilder.prototype.root = function() { | ||
return this.rootObject; | ||
}; | ||
XMLBuilder.prototype.toString = function(options) { | ||
@@ -67,0 +63,0 @@ var child, r, _i, _len, _ref; |
@@ -6,4 +6,4 @@ (function() { | ||
function XMLFragment(parent, name, attributes, text) { | ||
this.isDoc = false; | ||
this.isRoot = false; | ||
this.documentObject = null; | ||
this.parent = parent; | ||
@@ -43,3 +43,3 @@ this.name = name; | ||
this.assertLegalChar(text); | ||
child.text(text); | ||
child.raw(text); | ||
} | ||
@@ -51,3 +51,3 @@ this.children.push(child); | ||
var child, i, key, val, _ref, _ref2; | ||
if (this.isRoot || this.isDoc) { | ||
if (this.isRoot) { | ||
throw new Error("Cannot insert elements at root level"); | ||
@@ -81,3 +81,3 @@ } | ||
this.assertLegalChar(text); | ||
child.text(text); | ||
child.raw(text); | ||
} | ||
@@ -90,3 +90,3 @@ i = this.parent.children.indexOf(this); | ||
var child, i, key, val, _ref, _ref2; | ||
if (this.isRoot || this.isDoc) { | ||
if (this.isRoot) { | ||
throw new Error("Cannot insert elements at root level"); | ||
@@ -120,3 +120,3 @@ } | ||
this.assertLegalChar(text); | ||
child.text(text); | ||
child.raw(text); | ||
} | ||
@@ -129,3 +129,3 @@ i = this.parent.children.indexOf(this); | ||
var i, _ref; | ||
if (this.isRoot || this.isDoc) { | ||
if (this.isRoot) { | ||
throw new Error("Cannot remove the root element"); | ||
@@ -206,15 +206,7 @@ } | ||
XMLFragment.prototype.document = function() { | ||
var child; | ||
if (this.isDoc) { | ||
return this; | ||
} | ||
child = this.parent; | ||
while (!child.isDoc) { | ||
child = child.parent; | ||
} | ||
return child; | ||
return this.root().documentObject; | ||
}; | ||
XMLFragment.prototype.prev = function() { | ||
var i; | ||
if (this.isRoot || this.isDoc) { | ||
if (this.isRoot) { | ||
throw new Error("Root node has no siblings"); | ||
@@ -230,3 +222,3 @@ } | ||
var i; | ||
if (this.isRoot || this.isDoc) { | ||
if (this.isRoot) { | ||
throw new Error("Root node has no siblings"); | ||
@@ -277,3 +269,3 @@ } | ||
} | ||
if (!this.value) { | ||
if (!(this.value != null)) { | ||
r += '<' + this.name; | ||
@@ -293,3 +285,3 @@ } else { | ||
if (this.children.length === 0) { | ||
if (!this.value) { | ||
if (!(this.value != null)) { | ||
r += this.name === '?xml' ? '?>' : this.name === '!DOCTYPE' ? '>' : '/>'; | ||
@@ -296,0 +288,0 @@ } |
{ | ||
"name": "xmlbuilder", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"keywords": "xml xmlbuilder", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/oozcitak/xmlbuilder-js", |
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
14982
445