DomElementSchemaRegistry constructor

DomElementSchemaRegistry()

Implementation

DomElementSchemaRegistry() {
  for (var encodedType in _schema) {
    var parts = encodedType.split('|');
    var properties = parts[1].split(',');
    var typeParts = ('${parts[0]}^').split('^');
    var typeName = typeParts[0];
    var type = <String, String>{};
    var attributes = <String>{};
    var events = <String>{};
    var tags = typeName.split(',');
    for (var tag in tags) {
      schema[tag] = type;
      attributeSchema[tag] = attributes;
      eventSchema[tag] = events;
    }
    var superType = schema[typeParts[1]];
    superType?.forEach((k, v) => type[k] = v);
    var superAttributes = attributeSchema[typeParts[1]];
    superAttributes?.forEach((item) => attributes.add(item));
    var superEvents = eventSchema[typeParts[1]];
    superEvents?.forEach((item) => events.add(item));
    for (var property in properties) {
      if (property.isEmpty) continue;
      if (property.startsWith('*')) {
        events.add(property.substring(1).toLowerCase());
      }
      if (property.startsWith('!')) {
        type[property.substring(1)] = _boolean;
        attributes.add(_toAttribute(property.substring(1)));
      } else if (property.startsWith('#')) {
        type[property.substring(1)] = _number;
        attributes.add(_toAttribute(property.substring(1)));
      } else if (property.startsWith('%')) {
        type[property.substring(1)] = _object;
        attributes.add(_toAttribute(property.substring(1)));
      } else {
        type[property] = _string;
        attributes.add(_toAttribute(property));
      }
    }
  }
}