static getAttributes()

in src/js/webview/WebviewUtils.js [141:177]


  static getAttributes(element: Element): AttributeRecord[] {
    if (element == null) {
      return [];
    }
    let attributes = [...element.attributes]
      .filter(attr => !['class', 'id', 'style'].includes(attr.name))
      .map(attr => ({
        name: attr.name,
        value: attr.value,
        type:
          attr.name == 'datetime'
            ? RulePropertyTypes.DATETIME
            : attr.name == 'width' || attr.name == 'height'
              ? RulePropertyTypes.INTEGER
              : RulePropertyTypes.STRING,
      }));

    attributes.push({
      name: 'innerContent',
      value: element.textContent,
      type: RulePropertyTypes.ELEMENT,
    });

    attributes.push({
      name: 'textContent',
      value: element.textContent,
      type: RulePropertyTypes.STRING,
    });

    attributes.push({
      name: 'dateTextContent',
      value: element.textContent,
      type: RulePropertyTypes.DATETIME,
    });

    return attributes;
  }