devrelm / resize-observer

Other
98 stars 12 forks source link

Throw error when passing non-Element to unobserve() #6

Closed devrelm closed 6 years ago

devrelm commented 6 years ago

Chrome throws an error when a non-Element is passed to unobserve():

const ro = new ResizeObserver(() => console.log('hello!'));
ro.unobserve(null); // TypeError
ro.unobserve(undefined); // TypeError
ro.unobserve('cat'); // TypeError

Specifically, the error is:

Uncaught TypeError: Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element'.

This behavior is not specified in the spec, and I've opened an issue to get clarification added to the spec (WICG/ResizeObserver#53).

devrelm commented 6 years ago

Fixed by #10