dom: implement aborted method of abort signal (#37218)

Implement the `aborted` member of `AbortSignal`. Part of
https://github.com/servo/servo/issues/36935

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
This commit is contained in:
Gregory Terzian 2025-06-03 02:57:57 +08:00 committed by GitHub
parent dfa8dde1ca
commit 1dfc14d2fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -115,13 +115,19 @@ impl AbortSignal {
self.upcast::<EventTarget>()
.fire_event(atom!("abort"), can_gc);
}
/// <https://dom.spec.whatwg.org/#abortsignal-aborted>
fn aborted(&self) -> bool {
// An AbortSignal object is aborted when its abort reason is not undefined.
!self.abort_reason.get().is_undefined()
}
}
impl AbortSignalMethods<crate::DomTypeHolder> for AbortSignal {
/// <https://dom.spec.whatwg.org/#dom-abortsignal-aborted>
fn Aborted(&self) -> bool {
// TODO
false
// The aborted getter steps are to return true if this is aborted; otherwise false.
self.aborted()
}
/// <https://dom.spec.whatwg.org/#dom-abortsignal-reason>