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

I don't think there's any question that if there's an error, it should throw an exception. Any WebIDL errors, for example, throw exceptions. If the method can sometimes return `null`, the IDL and processing needs to be changed to define that.

The thing that needs to be specified is whether or not calling `animate()` on a element that is part of a document that is not part of the document tree is an error (and, if so, what specific type of error).

We allow `animate()` to be called on a element in a document without a browsing context and have [WPT for that](https://github.com/web-platform-tests/wpt/blob/master/web-animations/interfaces/Animatable/animate-no-browsing-context.html) but that WPT starts with [this comment](https://github.com/web-platform-tests/wpt/blob/18fda923cafeb4e3e0546ffcfb2302c3b1b11f98/web-animations/interfaces/Animatable/animate-no-browsing-context.html#L13-L17):

```js
//
// The following tests relate to animations on elements in documents without
// a browsing context. This is NOT the same as documents that are not bound to
// a document tree.
//
```

Apparently I wrote that comment in [Mozilla bug 1370123](https://bugzilla.mozilla.org/show_bug.cgi?id=1370123) but I don't recall the background there.

In this particular case, according to @BorisChiou's debugging, Gecko fails when it goes to look up the global for `target`. I'm not sure what Chromium fails on.

As far as the spec goes, it currently has:

> Construct a new [KeyframeEffect](https://drafts.csswg.org/web-animations-1/#keyframeeffect) object effect in the [relevant Realm](https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-realm) of target by using the same procedure as the [KeyframeEffect(target, keyframes, options)](https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-keyframeeffect) constructor, passing target as the target argument, and the keyframes and options arguments as supplied.
> 
> If the above procedure causes an exception to be thrown, propagate the exception and abort this procedure.

Perhaps we need to say something about failing to get the global for the relevant Realm?

-- 
GitHub Notification of comment by birtles
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11950#issuecomment-2731782567 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 18 March 2025 06:09:24 UTC