X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/fcecb8e0ed56cd955b1d2bcbc12e2675f40f0243..413a5f1dc25d5c8a788127f40816f39c49cd0d1c:/src/wlxml/wlxml.js diff --git a/src/wlxml/wlxml.js b/src/wlxml/wlxml.js index fe0636d..4f6e356 100644 --- a/src/wlxml/wlxml.js +++ b/src/wlxml/wlxml.js @@ -17,10 +17,26 @@ AttributesList.prototype.keys = function() { return _.keys(this); }; +var getClassLists = function(klassName) { + var toret = [], + classParts = [''].concat(klassName.split('.')), + classCurrent; + + classParts.forEach(function(part) { + classCurrent = classCurrent ? classCurrent + '.' + part : part; + toret.push(classCurrent); + }); + return toret; +}; + var installObject = function(instance, klass) { - var methods = instance.document.classMethods[klass] || {}, - transformations = instance.document.classTransformations[klass] || {}; + var methods = {}, + transformations = {}; + getClassLists(klass).forEach(function(klassName) { + _.extend(methods, instance.document.classMethods[klassName] || {}); + _.extend(methods, instance.document.classTransformations[klassName] || {}); + }); instance.object = Object.create(_.extend({}, methods, transformations)); _.keys(methods).concat(_.keys(transformations)).forEach(function(key) { instance.object[key] = _.bind(instance.object[key], instance); @@ -281,8 +297,9 @@ $.extend(WLXMLDocument.prototype, { registerClassTransformation: function(Transformation, className) { var thisClassTransformations = (this.classTransformations[className] = this.classTransformations[className] || {}); - thisClassTransformations[Transformation.prototype.name] = function(args) { + thisClassTransformations[Transformation.prototype.name] = function() { var nodeInstance = this; + var args = Array.prototype.slice.call(arguments, 0); return nodeInstance.transform(Transformation, args); }; },