Why isn’t setting attribute to an invalid value throwing?

As defined per WebIDL specification, setting attribute on an interface should convert the JS value to its IDL equivalent. It is explicitly stated that if the value cannot be converted it should throw a TypeError.

But why isn’t this throwing, but instead just failing silently?

document.onvisibilitychange = 4;
console.log(document.onvisibilitychange); // null