From: Aleksander Ɓukasz Date: Fri, 6 Dec 2013 11:38:25 +0000 (+0100) Subject: wip: extracting core transformations continued - detfineDocumentProperties from core X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/058d6f3448085c6f1d513691f8f2d5a12ae1d10a?ds=inline wip: extracting core transformations continued - detfineDocumentProperties from core --- diff --git a/src/smartxml/core.js b/src/smartxml/core.js index b5f8c44..bab584e 100644 --- a/src/smartxml/core.js +++ b/src/smartxml/core.js @@ -95,7 +95,7 @@ var elementNodeTransformations = { node.setData(this.getData()); if(this.sameNode(this.document.root)) { - defineDocumentProperties(this.document, node._$); + this.document._defineDocumentProperties(node._$); } this._$.replaceWith(node._$); this._setNativeNode(node._$[0]); diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index d74ec13..2ed9c47 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -305,7 +305,7 @@ $.extend(Document.prototype, Backbone.Events, { loadXML: function(xml, options) { options = options || {}; - defineDocumentProperties(this, $(parseXML(xml))); + this._defineDocumentProperties($(parseXML(xml))); if(!options.silent) { this.trigger('contentSet'); } @@ -452,18 +452,19 @@ $.extend(Document.prototype, Backbone.Events, { toret = toret.contents()[idx]; }); return toret; + }, + + _defineDocumentProperties: function($document) { + var doc = this; + Object.defineProperty(doc, 'root', {get: function() { + return doc.createDocumentNode($document[0]); + }, configurable: true}); + Object.defineProperty(doc, 'dom', {get: function() { + return $document[0]; + }, configurable: true}); } }); -var defineDocumentProperties = function(doc, $document) { - Object.defineProperty(doc, 'root', {get: function() { - return doc.createDocumentNode($document[0]); - }, configurable: true}); - Object.defineProperty(doc, 'dom', {get: function() { - return $document[0]; - }, configurable: true}); -}; - return { documentFromXML: function(xml) {