X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/14c5677515f8d609f9a57e6e08f15af1e32a0207..66cc0acfd75edaf656c8ce482421674a8d0fa126:/src/smartxml/smartxml.js?ds=sidebyside diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index 6b71026..248333e 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -9,6 +9,9 @@ var TEXT_NODE = Node.TEXT_NODE; var DocumentNode = function(nativeNode, document) { + if(!document) { + throw new Error('undefined document for a node'); + } this.document = document; this.nativeNode = nativeNode; this._$ = $(nativeNode); @@ -130,8 +133,13 @@ $.extend(ElementNode.prototype, DocumentNode.prototype, { element1: parent.contents()[myIdx + (moveLeftRange ? -1 : 0)], element2: parent.contents()[myIdx + childrenLength-1 + (moveRightRange ? 1 : 0)] }; - } + }, + toXML: function() { + var wrapper = $('
'); + wrapper.append(this._$); + return wrapper.html(); + } }); var TextNode = function(nativeNode, document) { @@ -177,6 +185,10 @@ $.extend(Document.prototype, { createTextNode: function(nativeNode) { return new this.TextNodeFactory(nativeNode, this); + }, + + toXML: function() { + return this.root.toXML(); } });