xmlbuilder
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -60,2 +60,3 @@ (function() { | ||
root = new XMLFragment(this, name, {}); | ||
root.isRoot = true; | ||
this.children.push(root); | ||
@@ -62,0 +63,0 @@ return root; |
@@ -6,2 +6,3 @@ (function() { | ||
function XMLFragment(parent, name, attributes, text) { | ||
this.isRoot = false; | ||
this.parent = parent; | ||
@@ -48,2 +49,5 @@ this.name = name; | ||
var child, i, key, val, _ref, _ref2; | ||
if (this.isRoot) { | ||
throw new Error("Cannot insert elements at root level"); | ||
} | ||
if (!(name != null)) { | ||
@@ -83,2 +87,5 @@ throw new Error("Missing element name"); | ||
var child, i, key, val, _ref, _ref2; | ||
if (this.isRoot) { | ||
throw new Error("Cannot insert elements at root level"); | ||
} | ||
if (!(name != null)) { | ||
@@ -118,3 +125,3 @@ throw new Error("Missing element name"); | ||
var i, _ref; | ||
if (!(this.parent != null)) { | ||
if (this.isRoot) { | ||
throw new Error("Cannot remove the root element"); | ||
@@ -178,3 +185,3 @@ } | ||
XMLFragment.prototype.up = function() { | ||
if (!(this.parent != null)) { | ||
if (this.isRoot) { | ||
throw new Error("This node has no parent"); | ||
@@ -184,6 +191,17 @@ } | ||
}; | ||
XMLFragment.prototype.root = function() { | ||
var child; | ||
if (this.isRoot) { | ||
return this; | ||
} | ||
child = this.parent; | ||
while (!child.isRoot) { | ||
child = child.parent; | ||
} | ||
return child; | ||
}; | ||
XMLFragment.prototype.prev = function() { | ||
var i; | ||
if (!(this.parent != null)) { | ||
throw new Error("This node has no parent"); | ||
if (this.isRoot) { | ||
throw new Error("Root node has no siblings"); | ||
} | ||
@@ -198,4 +216,4 @@ i = this.parent.children.indexOf(this); | ||
var i; | ||
if (!(this.parent != null)) { | ||
throw new Error("This node has no parent"); | ||
if (this.isRoot) { | ||
throw new Error("Root node has no siblings"); | ||
} | ||
@@ -202,0 +220,0 @@ i = this.parent.children.indexOf(this); |
{ | ||
"name": "xmlbuilder", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"keywords": "xml xmlbuilder", | ||
@@ -14,8 +14,6 @@ "homepage": "http://github.com/oozcitak/xmlbuilder-js", | ||
], | ||
"repositories": [ | ||
{ | ||
"type": "git", | ||
"url": "git://github.com/oozcitak/xmlbuilder-js.git" | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/oozcitak/xmlbuilder-js.git" | ||
}, | ||
"bugs": { | ||
@@ -22,0 +20,0 @@ "url": "http://github.com/oozcitak/xmlbuilder-js/issues" |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
14980
441
0