Hello already tried to use MutationObserver? I w...
# javascript
t
Hello already tried to use MutationObserver? I want to observer an input element:
Copy code
val el = document.querySelector("#my-element")!! as HTMLInputElement
    val observer = MutationObserver { _, _ ->
        println("changes")
    }

    observer.observe(el, MutationObserverInit(attributes = true))
But I'm always getting
Copy code
Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': The provided value cannot be converted to a sequence.
Any ideas?
a
Could you try passing
MutationObserverInit(attributes = true, attributeFilter = undefined)
instead?
@Tristan Caron I've been able to reproduce the error. It seems that the default value of attributeFilter (null) is causing the problem.
Setting it to undefined manually fixed the issue in my case
t
Whoua so efficient, thanks a lot.