murongg / vue3-lazyload

A Vue3.x image lazyload plugin
https://murongg.github.io/vue3-lazyload/
166 stars 19 forks source link

TypeError: Failed to execute 'unobserve' on 'IntersectionObserver': parameter 1 is not of type 'Element'. #30

Closed binvb closed 2 years ago

binvb commented 2 years ago

i was get error from user report, but i can not find why this happend, can you help?

murongg commented 2 years ago

Can you provide mini repo?

binvb commented 2 years ago

Can you provide mini repo?

i found the @latest version already fix this:

  public update(el: HTMLElement, binding: string | DirectiveBinding<string | ValueFormatterObject>): void {
    if (!el)
      return
    this._realObserver(el)?.unobserve(el)
    const { src, error, lifecycle, delay } = this._valueFormatter(typeof binding === 'string' ? binding : binding.value)
    this._initIntersectionObserver(el, src, error, lifecycle, delay)
  }

but i was wondering when the el object will return null, it's glad to get your answer.

murongg commented 2 years ago

Can you provide mini repo?

i found the @latest version already fix this:

  public update(el: HTMLElement, binding: string | DirectiveBinding<string | ValueFormatterObject>): void {
    if (!el)
      return
    this._realObserver(el)?.unobserve(el)
    const { src, error, lifecycle, delay } = this._valueFormatter(typeof binding === 'string' ? binding : binding.value)
    this._initIntersectionObserver(el, src, error, lifecycle, delay)
  }

but i was wondering when the el object will return null, it's glad to get your answer.

When the dom has not been mounted or after unmounted.