Skip to content

Commit

Permalink
Merge pull request #1572 from didi/fix-intersection-web-promise
Browse files Browse the repository at this point in the history
fix: IntersectionObserver 删除无用的 promise
  • Loading branch information
hiyuki authored Aug 28, 2024
2 parents 5372674 + 7faad8b commit b9fc674
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ class WebIntersectionObserver {
}

observe (targetSelector, callback) {
nextTick(async () => {
if (!targetSelector) {
const res = { errMsg: 'observe:targetSelector can not be empty' }
return Promise.reject(res)
nextTick(() => {
if (!document.querySelector(targetSelector)) {
console.warn(`[mpx runtime warn]: Node ${JSON.stringify(targetSelector)} is not found. Intersection observer will not trigger.`)
return
}
this._observer = await this.initObserver()
this._observer = this.initObserver()
this._callback = callback
let targetElement = []
if (this._options.observeAll) {
Expand Down

0 comments on commit b9fc674

Please sign in to comment.