-var ElementsRegister = function() {
- this._register = {
- '': ElementsRegister.createCanvasElementType(genericElement, documentElement.DocumentNodeElement)
- };
-
-}
-_.extend(ElementsRegister, {
- createCanvasElementType: function(elementPrototype, inheritFrom) {
- var Constructor = function() {
- if(!this.super) {
- this.super = inheritFrom.prototype;
- }
- inheritFrom.apply(this, Array.prototype.slice.call(arguments, 0));
-
- };
- Constructor.prototype = Object.create(inheritFrom.prototype);
- _.extend(Constructor.prototype, elementPrototype);
- return Constructor;
- }
-});
-_.extend(ElementsRegister.prototype, {
- register: function(klass, elementPrototype) {
- this._register[klass] = ElementsRegister.createCanvasElementType(elementPrototype, this.getFactoryFor(''));
- },
- getFactoryFor: function(klass) {
- var Factory;
- wlxml.getClassHierarchy(klass).reverse().some(function(klass) {
- Factory = this._register[klass];
- if(Factory) {
- return true;
- }
- }.bind(this));
- return Factory;
- }
-});