All files / src/material-toolbox utils.js

77.78% Statements 7/9
60% Branches 3/5
100% Functions 4/4
75% Lines 6/8

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 34 35 36 37 38 39      97x 39x         100x                                 5x 5x                 5x    
// @flow strict
 
// flowlint-next-line unclear-type:off
export const getDisplayName = (WrappedComponent: any) => {
  return WrappedComponent.displayName || WrappedComponent.name;
};
 
// eslint-disable-next-line
export function normalizePropToReactStyle(property: string): string {
  return property.replace(/(-.)/g, txt => txt.slice(1).toUpperCase());
}
 
/**
 * From https://github.com/material-components/material-components-web/blob/master/packages/mdc-base/component.js
 * Fires a cross-browser-compatible custom event from the component root of the given type,
 * with the given data.
 * @param {string} evtType
 * @param {!Object} evtData
 * @param {boolean=} shouldBubble
 */
export function createEvent(
  evtType: string,
  evtData: {},
  shouldBubble: boolean = false,
) {
  let evt;
  Eif (typeof CustomEvent === 'function') {
    evt = new CustomEvent(evtType, {
      detail: evtData,
      bubbles: shouldBubble,
    });
  } else {
    evt = document.createEvent('CustomEvent');
    evt.initCustomEvent(evtType, shouldBubble, false, evtData);
  }
 
  return evt;
}