var parseXML = function(xml) {
return $(xml)[0];
-}
+};
var Document = function(nativeNode) {
var $document = $(nativeNode);
- Object.defineProperty(this, 'root', {get: function() { return new ElementNode($document[0])}});
-}
+ Object.defineProperty(this, 'root', {get: function() { return new ElementNode($document[0]);}});
+};
var DocumentNode = function(nativeNode) {
this.nativeNode = nativeNode;
this._$ = $(nativeNode);
-}
+};
$.extend(DocumentNode.prototype, {
detach: function() { this._$.detach(); },
sameNode: function(otherNode) {
return this.nativeNode === otherNode.nativeNode;
}
-})
+});
var ElementNode = function(nativeNode) {
DocumentNode.apply(this, arguments);
var TextNode = function(nativeNode) {
DocumentNode.apply(this, arguments);
-}
+};
$.extend(TextNode.prototype, DocumentNode.prototype, {
nodeType: Node.TEXT_NODE,
prependText: function(text) {
this.nativeNode.data = text + this.nativeNode.data;
}
-})
+});
return {
var getDocumentFromXML = function(xml) {
return smartxml.documentFromXML(xml);
-}
+};
var elementNodeFromParams = function(params) {
return smartxml.elementNodeFromXML('<' + params.tag + '></' + params.tag + '>');
-}
+};
var elementNodeFromXML = function(xml) {
return smartxml.elementNodeFromXML(xml);
-}
+};
describe.only('smartxml', function() {
expect(contents[1].nodeType).to.equal(Node.ELEMENT_NODE, 'element node 1');
expect(contents[2].nodeType).to.equal(Node.TEXT_NODE, 'text node 2');
});
- })
+ });
describe('Manipulations', function() {