DOMElement constructor

DOMElement(
  1. String? tag, {
  2. Map<String, dynamic>? attributes,
  3. Object? id,
  4. Object? classes,
  5. Object? style,
  6. Object? content,
  7. bool? hidden,
  8. bool commented = false,
})

Implementation

factory DOMElement(String? tag,
    {Map<String, dynamic>? attributes,
    Object? id,
    Object? classes,
    Object? style,
    Object? content,
    bool? hidden,
    bool commented = false}) {
  tag = _normalizeTag(tag);

  switch (tag) {
    case 'div':
      return DIVElement(
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          content: content,
          hidden: hidden,
          commented: commented);

    case 'input':
      {
        var type = attributes?['type'];

        if (type == 'checkbox') {
          return CHECKBOXElement(
              attributes: attributes,
              id: id,
              classes: classes,
              style: style,
              value: content,
              hidden: hidden,
              commented: commented);
        }

        return INPUTElement(
            attributes: attributes,
            id: id,
            classes: classes,
            style: style,
            value: content,
            hidden: hidden,
            commented: commented);
      }

    case 'select':
      return SELECTElement(
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          options: content,
          hidden: hidden,
          commented: commented);

    case 'option':
      return OPTIONElement(
        attributes: attributes,
        classes: classes,
        style: style,
        text: DOMNode.toText(content),
      );

    case 'textarea':
      return TEXTAREAElement(
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          content: content,
          hidden: hidden,
          commented: commented);

    case 'table':
      return TABLEElement(
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          content: content,
          hidden: hidden,
          commented: commented);

    case 'thead':
      return THEADElement(
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          rows: content,
          hidden: hidden,
          commented: commented);

    case 'caption':
      return CAPTIONElement(
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          content: content,
          hidden: hidden,
          commented: commented);

    case 'tbody':
      return TBODYElement(
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          rows: content,
          hidden: hidden,
          commented: commented);

    case 'tfoot':
      return TFOOTElement(
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          rows: content,
          hidden: hidden,
          commented: commented);

    case 'tr':
      return TRowElement(
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          cells: content,
          hidden: hidden,
          commented: commented);

    case 'td':
      return TDElement(
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          content: content,
          hidden: hidden,
          commented: commented);

    case 'th':
      return THElement(
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          content: content,
          hidden: hidden,
          commented: commented);

    default:
      return DOMElement._(tag,
          attributes: attributes,
          id: id,
          classes: classes,
          style: style,
          content: content,
          hidden: hidden,
          commented: commented);
  }
}