X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/16c90b3616f1645aab9fe284fd3b89641dfb42f2..a849d4765ded55173cc10ba3e55a483d281b9174:/src/wlxml/wlxml.js diff --git a/src/wlxml/wlxml.js b/src/wlxml/wlxml.js index fe0636d..9fb6a98 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);