X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/da6bb077bae1614af05e0071fbfbe6ddddf4c267..24e73bdbeb5e83ff18d2f9b359e7b41fe8230c1a:/src/smartxml/smartxml.js diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index 04449cf..43e3041 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -29,7 +29,21 @@ $.extend(DocumentNode.prototype, { sameNode: function(otherNode) { return this.nativeNode === otherNode.nativeNode; - } + }, + + parent: function() { + return this.nativeNode.parentNode ? new ElementNode(this.nativeNode.parentNode) : null; + }, + + before: function(node) { + this._$.before(node.nativeNode); + }, + + wrapWith: function(node) { + if(this.parent()) + this.before(node); + node.append(this); + }, }); var ElementNode = function(nativeNode) { @@ -58,10 +72,6 @@ $.extend(ElementNode.prototype, DocumentNode.prototype, { return this._$.contents().index(node._$); }, - parent: function() { - return new ElementNode(this._$.parent()); - }, - getAttr: function(name) { return this._$.attr(name); }, @@ -74,10 +84,6 @@ $.extend(ElementNode.prototype, DocumentNode.prototype, { this._$.append(documentNode.nativeNode); }, - before: function(node) { - this._$.before(node.nativeNode); - }, - unwrapContent: function() { var parent = this.parent(); if(!parent)