WICG / resize-observer

This repository is no longer active. ResizeObserver has moved out of WICG into
https://github.com/w3c/csswg-drafts/tree/master/resize-observer-1
Other
255 stars 18 forks source link

Clarify behavior around passing null/undefined to unobserve #53

Closed devrelm closed 6 years ago

devrelm commented 6 years ago

What should be the behavior when passing null or undefined to unobserve()?

The spec does not define one way or another (unless there's a wider convention/context that I've missed.)

Chrome's implementation currently throws an error if the first argument is not an Element.

There are no tests (in this repo) defining this behavior, either.

domfarolino commented 6 years ago

@devrelm Throwing a TypeError is the correct behavior. The convention you are referring to in this case can be seen in the WebIDL spec where we try to convert something to an interface. Note in step 1, Type(target) will not return Object in the case where target is null or undefined so we'll be caught red-handed here :)

Edit:

Let me know if that makes sense or needs more clarification!

devrelm commented 6 years ago

Thanks, that is very informative! I had never looked at the IDL spec and so never realized that it was defined so thoroughly.