1 define(function(require) {
 
   4 var _ = require('libs/underscore'),
 
   5     wlxml = require('wlxml/wlxml');
 
   8 var ElementsRegister = function(BaseType, NullType) {
 
  10     this.BaseType = BaseType;
 
  11     this.NullType = NullType;
 
  14 _.extend(ElementsRegister.prototype, {
 
  15     createCanvasElementType: function(elementPrototype) {
 
  17         var Constructor = function() {
 
  18             register.BaseType.apply(this, Array.prototype.slice.call(arguments, 0));
 
  20         Constructor.prototype = elementPrototype;
 
  23     register: function(params) {
 
  24         params.klass = params.klass || '';
 
  25         params.prototype = params.prototype || this.NullType;
 
  27         this._register[params.tag] = this._register[params.tag] || {};
 
  28         this._register[params.tag][params.klass] = this.createCanvasElementType(params.prototype);
 
  30     getElement: function(params) {
 
  31         params.klass = params.klass || '';
 
  33         if(this._register[params.tag]) {
 
  34             wlxml.getClassHierarchy(params.klass).reverse().some(function(klass) {
 
  35                 Factory = this._register[params.tag][klass];
 
  42             Factory = this.BaseType;
 
  49 return ElementsRegister;