var DocumentNode = function(nativeNode, document) {
+ if(!document) {
+ throw new Error('undefined document for a node');
+ }
this.document = document;
this.nativeNode = nativeNode;
this._$ = $(nativeNode);
element1: parent.contents()[myIdx + (moveLeftRange ? -1 : 0)],
element2: parent.contents()[myIdx + childrenLength-1 + (moveRightRange ? 1 : 0)]
};
- }
+ },
+ toXML: function() {
+ var wrapper = $('<div>');
+ wrapper.append(this._$);
+ return wrapper.html();
+ }
});
var TextNode = function(nativeNode, document) {
Object.defineProperty(this, 'root', {get: function() {
return doc.createElementNode($document[0]);
}});
+ Object.defineProperty(this, 'dom', {get: function() {
+ return $document[0];
+ }});
};
$.extend(Document.prototype, {
ElementNodeFactory: ElementNode,
createTextNode: function(nativeNode) {
return new this.TextNodeFactory(nativeNode, this);
+ },
+
+ toXML: function() {
+ return this.root.toXML();
}
});