1
import VNode from '../VNode';
2 4
import { SYNTHETIC_TYPES } from './constants';
3

4 4
export const isPropagationStopped: {
5
  [key: string]: boolean;
6
} = {};
7

8 4
SYNTHETIC_TYPES.forEach(type => {
9 4
  isPropagationStopped[type] = false;
10
});
11

12
/**
13
 * 检查父元素里还有没有点击事件
14
 *
15
 * @export
16
 * @param {VNode} node
17
 * @returns
18
 */
19 4
export function validate(node: VNode, eventType: string) {
20 4
  const parent = node.parent;
21

22 4
  if (!parent) {
23 4
    isPropagationStopped[eventType] = false;
24 4
    return;
25
  }
26

27 4
  if (parent.props?.[eventType]) {
28 4
    return;
29
  }
30

31 4
  validate(parent, eventType);
32
}
33

34 4
export default function stopPropagation(node: VNode, eventType: string) {
35 4
  isPropagationStopped[eventType] = true;
36

37 4
  validate(node, eventType);
38
}

Read our documentation on viewing source code .

Loading