Skip to content

Commit

Permalink
fix(runtime-web): this.createIntersectionObserver 类型错误 (eleme#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
hwaphon authored Sep 1, 2023
1 parent c22c2a2 commit ec4316a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/runtime-web/src/runtime/public/utils/instanceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IntersectionObserverOptions } from '../../../api/ui/element-query/inter

export function mountIntersectionObserver(
options: IntersectionObserverOptions,
root: HTMLElement | null
root: Element | Text | null
) {
const intersectionObserver = my.createIntersectionObserver(options)
// 保存一份引用,且固定 this 绑定
Expand All @@ -14,7 +14,10 @@ export function mountIntersectionObserver(
let element = null
if (root) {
// 查看要遍历的组件是不是自定义节点最外层的节点
if (typeof root.matches === 'function' && root.matches(targetSelector))
if (
typeof (root as HTMLElement).matches === 'function' &&
(root as HTMLElement).matches(targetSelector)
)
element = root
else if (root.parentNode)
element = root.parentNode.querySelector(targetSelector)
Expand Down

0 comments on commit ec4316a

Please sign in to comment.