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. String? role,
  9. String? ariaLabel,
  10. Map<String, Object?>? aria,
  11. int? tabIndex,
  12. bool commented = false,
})

An element of tag (its specialized class, when there's one: DIVElement, INPUTElement...). role, ariaLabel, aria and tabIndex are its accessibility attributes (setAccessibility).

Implementation

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

  switch (tag) {
    case 'div':
      return DIVElement(
        attributes: attributes,
        id: id,
        classes: classes,
        style: style,
        content: content,
        hidden: hidden,
        role: role,
        ariaLabel: ariaLabel,
        aria: aria,
        tabIndex: tabIndex,
        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,
            role: role,
            ariaLabel: ariaLabel,
            aria: aria,
            tabIndex: tabIndex,
            commented: commented,
          );
        }

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

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

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

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

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

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

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

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

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

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

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

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

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