Skip to content

[web-animations-1] The expected behavior when calling animate() on the removed element #11950

@BorisChiou

Description

@BorisChiou

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions