Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MutationObserver.observe() should not have optional second argument #982

Open
diesal11 opened this issue Feb 24, 2021 · 1 comment
Open

Comments

@diesal11
Copy link

According to MutationObserver MDN docs, calling .observe() without an options argument will throw a type error.

The docs for the options type MutationObserverInit state that:

At a minimum, one of childList, attributes, and/or characterData must be true when you call observe(). Otherwise, a TypeError exception will be thrown.

However, all of childList, attributes & characterData are false by default, including when an options argument is not provided. Therefore i believe that the secondary argument for observe() being optional is incorrect.

@felipe-sme
Copy link

Yep, Typescript marks the MutationObserver observe method signature as MutationObserver.observe(target: Node, options?: MutationObserverInit): void. Calling it without an options object doesn't give you a static error, but you'll get a runtime type error as it isn't optional. At least one of the properties needs to be passed in as true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants