export function attachEventProps()

in packages/synchro-charts-react/src/react-component-lib/utils/attachEventProps.ts [1:22]


export function attachEventProps(node: HTMLElement, newProps: any, oldProps: any = {}) {
  const className = getClassName(node.classList, newProps, oldProps);
  if (className) {
    node.className = className;
  }

  Object.keys(newProps).forEach(name => {
    if (name === 'children' || name === 'style' || name === 'ref' || name === 'className') {
      return;
    }
    if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
      const eventName = name.substring(2);
      const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);

      if (!isCoveredByReact(eventNameLc)) {
        syncEvent(node, eventNameLc, newProps[name]);
      }
    } else {
      (node as any)[name] = newProps[name];
    }
  });
}