This is from a Gecko bug: Bug 1950717.
Per spec, when calling animate(), we should return an Animation object.
However, what is the expected behavior if there are any errors? Here is a simple test case:
<script>
function run() {
let iframe = document.createElement('iframe');
container.appendChild(iframe);
let target = iframe.contentDocument.createElement('div');
window.setTimeout(() => {
iframe.remove();
let anims = target.animate(
[ { opacity: 0 }, { opacity: 1 } ],
1000);
console.log(anims);
}, 100);
}
</script>
<body onload="run()">
<div id="container"></div>
</body>
The target is removed, so it's impossible to create an Animation. In Blink, it just returns null. In Gecko, it throws a bowser-defined error, NS_ERROR_FAILURE. In WebKit, it returns an Animation.
I think it'd be nice to define the behavior when any errors happen.
cc @birtles