Skip to content

Commit 67fc089

Browse files
committed
fix: 优化requestAnimationFrame兼容代码的实现
1 parent 6a0cb06 commit 67fc089

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

packages/core/src/view/node/BaseNode.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createElement as h, Component } from 'preact/compat'
22
import { reaction, IReactionDisposer } from 'mobx'
3-
import { map } from 'lodash-es'
3+
import { map, isFunction, isNil } from 'lodash-es'
44
import Anchor from '../Anchor'
55
import { BaseText } from '../text'
66
import LogicFlow from '../../LogicFlow'
@@ -410,8 +410,7 @@ export abstract class BaseNode<P extends IProps = IProps> extends Component<
410410
// 复制粘贴后会出现点击节点时,节点会失去焦点的问题,这里手动让节点获焦以解决这个问题
411411
const el = e.currentTarget as HTMLElement
412412
const rAF =
413-
typeof window !== 'undefined' &&
414-
typeof window.requestAnimationFrame === 'function'
413+
!isNil(window) && isFunction(window.requestAnimationFrame)
415414
? window.requestAnimationFrame.bind(window)
416415
: (fn: () => void) => setTimeout(fn, 0)
417416
rAF(() => {

0 commit comments

Comments
 (0)