All files / builder/platform/zfb zfb.transform.ts

100% Statements 15/15
100% Branches 8/8
100% Functions 3/3
100% Lines 15/15

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 341x 1x 1x   1x 1x 1x 5x 2x   49x 49x 13x           36x 36x 1x           35x              
import { capitalize } from '@angular-devkit/core/src/utils/strings';
import { Injectable } from 'static-injector';
import { WxTransformLike } from '../template-transform-strategy/wx-like/wx-transform.base';
 
const BIND_PREFIX_REGEXP = /^(bind|mut-bind|capture-bind)(.*)/;
const CATCH_PREFIX_REGEXP = /^(catch|capture-catch)(.*)/;
@Injectable()
export class ZfbTransform extends WxTransformLike {
  directivePrefix = 'a';
  override eventNameConvert(name: string) {
    let result = name.match(BIND_PREFIX_REGEXP);
    if (result) {
      return {
        prefix: 'on',
        type: result[2],
        name: `on${capitalize(result[2])}`,
      };
    }
    result = name.match(CATCH_PREFIX_REGEXP);
    if (result) {
      return {
        prefix: 'catch',
        type: result[2],
        name: `catch${capitalize(result[2])}`,
      };
    }
    return {
      prefix: 'on',
      type: name,
      name: `on${capitalize(name)}`,
    };
  }
}