# All files / src/html warnings.ts

72.72% Statements 8/11
50% Branches 1/2
66.66% Functions 2/3
72.72% Lines 8/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    347x

    16x
    16x

    7x

    4x
    4x
    4x

    4x

     import * as logger from '../utils/logger';
    import { MbNode } from '../utils/node';

    /**
     * Check and warns if element has conflicting attributes.
     * Note that attirbutes in `attrsConflictingWith` are not in conflict with each other,
     * but only towards `attribute`
     * @param node Root element to check
     * @param attribute An attribute that is conflicting with other attributes
     * @param attrsConflictingWith The attributes conflicting with `attribute`
     */
    function _warnConflictingAttributes(node: MbNode, attribute: string, attrsConflictingWith: string[]) {
      if (!(attribute in node.attribs)) {
        return;
      }

      attrsConflictingWith.forEach((conflictingAttr) => {
        Iif (conflictingAttr in node.attribs) {
          logger.warn(`Usage of conflicting ${node.name} attributes: `
              + `'${attribute}' with '${conflictingAttr}'`);
        }
      });
    }

    export const warnConflictingAtributesMap: { [attr: string]: (nd: MbNode) => void } = {
      box: (node) => {
        _warnConflictingAttributes(node, 'light', ['seamless']);
        _warnConflictingAttributes(node, 'no-background', ['background-color', 'seamless']);
        _warnConflictingAttributes(node, 'no-border',
                                   ['border-color', 'border-left-color', 'seamless']);
        _warnConflictingAttributes(node, 'no-icon', ['icon']);
      },
    };