X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/fd6329db57fc3cc1cf2305da8d0127de4f2198e2..2a63804a0f4838a7016c84735df10dde26f8bb38:/src/smartxml/smartxml.js diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index d74ec13..b28f8d1 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -235,8 +235,9 @@ var registerTransformation = function(desc, name, target) { var Transformation = transformations.createContextTransformation(desc, name); //+ to sie powinna nazywac registerTransformationFromDesc or sth //+ ew. spr czy nie override (tylko jesli powyzej sa prototypy to trudno do nich dojsc) - target[name] = function(args) { - var instance = this; + target[name] = function() { + var instance = this, + args = Array.prototype.slice.call(arguments, 0); return instance.transform(Transformation, args); } }; @@ -305,7 +306,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 +453,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) {